"""Initial migration Revision ID: c72667903a91 Revises: Create Date: 2025-07-10 08:35:55.412151 """ from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = 'c72667903a91' down_revision = None branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('kanban_card') op.drop_table('kanban_column') op.drop_table('kanban_board') op.drop_index(op.f('idx_invitation_company'), table_name='company_invitation') op.drop_index(op.f('idx_invitation_email'), table_name='company_invitation') op.drop_index(op.f('idx_invitation_expires'), table_name='company_invitation') op.drop_index(op.f('idx_invitation_token'), table_name='company_invitation') op.drop_constraint(op.f('company_settings_created_by_id_fkey'), 'company_settings', type_='foreignkey') op.drop_column('company_settings', 'allow_team_visibility_comments') op.drop_column('company_settings', 'round_time_to') op.drop_column('company_settings', 'time_tracking_mode') op.drop_column('company_settings', 'enable_projects') op.drop_column('company_settings', 'default_comment_visibility') op.drop_column('company_settings', 'require_task_assignment') op.drop_column('company_settings', 'enable_teams') op.drop_column('company_settings', 'require_project_selection') op.drop_column('company_settings', 'restrict_project_access_by_team') op.drop_column('company_settings', 'enable_invoicing') op.drop_column('company_settings', 'auto_break_deduction') op.drop_column('company_settings', 'allow_task_creation_by_members') op.drop_column('company_settings', 'created_by_id') op.drop_column('company_settings', 'enable_reports') op.drop_column('company_settings', 'require_daily_notes') op.drop_column('company_settings', 'min_hours_per_entry') op.drop_column('company_settings', 'default_currency') op.drop_column('company_settings', 'allow_manual_time') op.drop_constraint(op.f('uq_company_work_config'), 'company_work_config', type_='unique') op.drop_index(op.f('idx_note_folder'), table_name='note') op.drop_index(op.f('idx_note_folder_company'), table_name='note_folder') op.drop_index(op.f('idx_note_folder_created_by'), table_name='note_folder') op.drop_index(op.f('idx_note_folder_parent_path'), table_name='note_folder') op.drop_constraint(op.f('note_link_target_note_id_fkey'), 'note_link', type_='foreignkey') op.drop_constraint(op.f('note_link_source_note_id_fkey'), 'note_link', type_='foreignkey') op.create_foreign_key(None, 'note_link', 'note', ['target_note_id'], ['id'], ondelete='CASCADE') op.create_foreign_key(None, 'note_link', 'note', ['source_note_id'], ['id'], ondelete='CASCADE') op.drop_index(op.f('idx_note_share_created_by'), table_name='note_share') op.drop_index(op.f('idx_note_share_note_id'), table_name='note_share') op.drop_index(op.f('idx_note_share_token'), table_name='note_share') op.drop_table_comment( 'note_share', existing_comment='Public sharing links for notes with optional password protection and view limits', schema=None ) op.alter_column('project_category', 'name', existing_type=sa.VARCHAR(length=100), type_=sa.String(length=50), existing_nullable=False) op.alter_column('project_category', 'description', existing_type=sa.TEXT(), type_=sa.String(length=255), existing_nullable=True) op.drop_constraint(op.f('project_category_created_by_id_fkey'), 'project_category', type_='foreignkey') op.drop_column('project_category', 'icon') op.drop_column('project_category', 'created_by_id') op.drop_column('project_category', 'updated_at') op.alter_column('sub_task', 'status', existing_type=postgresql.ENUM('TODO', 'IN_PROGRESS', 'IN_REVIEW', 'DONE', 'CANCELLED', 'ARCHIVED', 'In Progress', 'To Do', 'Cancelled', 'In Review', 'Archived', 'Done', name='taskstatus'), nullable=True, existing_server_default=sa.text("'TODO'::taskstatus")) op.alter_column('task', 'status', existing_type=postgresql.ENUM('TODO', 'IN_PROGRESS', 'IN_REVIEW', 'DONE', 'CANCELLED', 'ARCHIVED', 'In Progress', 'To Do', 'Cancelled', 'In Review', 'Archived', 'Done', name='taskstatus'), nullable=True, existing_server_default=sa.text("'TODO'::taskstatus")) op.drop_index(op.f('idx_user_default_dashboard'), table_name='user_dashboard') op.drop_constraint(op.f('user_preferences_default_project_id_fkey'), 'user_preferences', type_='foreignkey') op.drop_column('user_preferences', 'daily_summary') op.drop_column('user_preferences', 'mention_notifications') op.drop_column('user_preferences', 'pomodoro_duration') op.drop_column('user_preferences', 'keyboard_shortcuts') op.drop_column('user_preferences', 'week_start') op.drop_column('user_preferences', 'default_project_id') op.drop_column('user_preferences', 'sound_enabled') op.drop_column('user_preferences', 'email_notifications') op.drop_column('user_preferences', 'task_assigned_notifications') op.drop_column('user_preferences', 'pomodoro_enabled') op.drop_column('user_preferences', 'email_daily_summary') op.drop_column('user_preferences', 'email_weekly_summary') op.drop_column('user_preferences', 'task_reminders') op.drop_column('user_preferences', 'auto_start_timer') op.drop_column('user_preferences', 'weekly_report') op.drop_column('user_preferences', 'push_notifications') op.drop_column('user_preferences', 'compact_mode') op.drop_column('user_preferences', 'pomodoro_break') op.drop_column('user_preferences', 'idle_time_detection') op.drop_column('user_preferences', 'task_completed_notifications') op.drop_column('user_preferences', 'show_weekends') # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('user_preferences', sa.Column('show_weekends', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('task_completed_notifications', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('idle_time_detection', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('pomodoro_break', sa.INTEGER(), server_default=sa.text('5'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('compact_mode', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('push_notifications', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('weekly_report', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('auto_start_timer', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('task_reminders', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('email_weekly_summary', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('email_daily_summary', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('pomodoro_enabled', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('task_assigned_notifications', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('email_notifications', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('sound_enabled', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('default_project_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('week_start', sa.INTEGER(), server_default=sa.text('1'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('keyboard_shortcuts', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('pomodoro_duration', sa.INTEGER(), server_default=sa.text('25'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('mention_notifications', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('user_preferences', sa.Column('daily_summary', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.create_foreign_key(op.f('user_preferences_default_project_id_fkey'), 'user_preferences', 'project', ['default_project_id'], ['id']) op.create_index(op.f('idx_user_default_dashboard'), 'user_dashboard', ['user_id', 'is_default'], unique=False) op.alter_column('task', 'status', existing_type=postgresql.ENUM('TODO', 'IN_PROGRESS', 'IN_REVIEW', 'DONE', 'CANCELLED', 'ARCHIVED', 'In Progress', 'To Do', 'Cancelled', 'In Review', 'Archived', 'Done', name='taskstatus'), nullable=False, existing_server_default=sa.text("'TODO'::taskstatus")) op.alter_column('sub_task', 'status', existing_type=postgresql.ENUM('TODO', 'IN_PROGRESS', 'IN_REVIEW', 'DONE', 'CANCELLED', 'ARCHIVED', 'In Progress', 'To Do', 'Cancelled', 'In Review', 'Archived', 'Done', name='taskstatus'), nullable=False, existing_server_default=sa.text("'TODO'::taskstatus")) op.add_column('project_category', sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) op.add_column('project_category', sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=False)) op.add_column('project_category', sa.Column('icon', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) op.create_foreign_key(op.f('project_category_created_by_id_fkey'), 'project_category', 'user', ['created_by_id'], ['id']) op.alter_column('project_category', 'description', existing_type=sa.String(length=255), type_=sa.TEXT(), existing_nullable=True) op.alter_column('project_category', 'name', existing_type=sa.String(length=50), type_=sa.VARCHAR(length=100), existing_nullable=False) op.create_table_comment( 'note_share', 'Public sharing links for notes with optional password protection and view limits', existing_comment=None, schema=None ) op.create_index(op.f('idx_note_share_token'), 'note_share', ['token'], unique=False) op.create_index(op.f('idx_note_share_note_id'), 'note_share', ['note_id'], unique=False) op.create_index(op.f('idx_note_share_created_by'), 'note_share', ['created_by_id'], unique=False) op.drop_constraint(None, 'note_link', type_='foreignkey') op.drop_constraint(None, 'note_link', type_='foreignkey') op.create_foreign_key(op.f('note_link_source_note_id_fkey'), 'note_link', 'note', ['source_note_id'], ['id']) op.create_foreign_key(op.f('note_link_target_note_id_fkey'), 'note_link', 'note', ['target_note_id'], ['id']) op.create_index(op.f('idx_note_folder_parent_path'), 'note_folder', ['parent_path'], unique=False) op.create_index(op.f('idx_note_folder_created_by'), 'note_folder', ['created_by_id'], unique=False) op.create_index(op.f('idx_note_folder_company'), 'note_folder', ['company_id'], unique=False) op.create_index(op.f('idx_note_folder'), 'note', ['folder'], unique=False) op.create_unique_constraint(op.f('uq_company_work_config'), 'company_work_config', ['company_id']) op.add_column('company_settings', sa.Column('allow_manual_time', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('default_currency', sa.VARCHAR(length=3), server_default=sa.text("'USD'::character varying"), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('min_hours_per_entry', postgresql.DOUBLE_PRECISION(precision=53), server_default=sa.text('0.0'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('require_daily_notes', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('enable_reports', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('allow_task_creation_by_members', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('auto_break_deduction', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('enable_invoicing', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('restrict_project_access_by_team', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('require_project_selection', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('enable_teams', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('require_task_assignment', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('default_comment_visibility', postgresql.ENUM('TEAM', 'COMPANY', name='commentvisibility'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('enable_projects', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('time_tracking_mode', sa.VARCHAR(length=20), server_default=sa.text("'flexible'::character varying"), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('round_time_to', sa.INTEGER(), server_default=sa.text('1'), autoincrement=False, nullable=True)) op.add_column('company_settings', sa.Column('allow_team_visibility_comments', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.create_foreign_key(op.f('company_settings_created_by_id_fkey'), 'company_settings', 'user', ['created_by_id'], ['id']) op.create_index(op.f('idx_invitation_token'), 'company_invitation', ['token'], unique=False) op.create_index(op.f('idx_invitation_expires'), 'company_invitation', ['expires_at'], unique=False) op.create_index(op.f('idx_invitation_email'), 'company_invitation', ['email'], unique=False) op.create_index(op.f('idx_invitation_company'), 'company_invitation', ['company_id'], unique=False) op.create_table('kanban_board', sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('kanban_board_id_seq'::regclass)"), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=False), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('company_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('is_default', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['company_id'], ['company.id'], name='kanban_board_company_id_fkey'), sa.ForeignKeyConstraint(['created_by_id'], ['user.id'], name='kanban_board_created_by_id_fkey'), sa.PrimaryKeyConstraint('id', name='kanban_board_pkey'), sa.UniqueConstraint('company_id', 'name', name='uq_kanban_board_name_per_company'), postgresql_ignore_search_path=False ) op.create_table('kanban_column', sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('kanban_column_id_seq'::regclass)"), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=False), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('position', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('color', sa.VARCHAR(length=7), autoincrement=False, nullable=True), sa.Column('wip_limit', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('board_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['board_id'], ['kanban_board.id'], name='kanban_column_board_id_fkey'), sa.PrimaryKeyConstraint('id', name='kanban_column_pkey'), sa.UniqueConstraint('board_id', 'name', name='uq_kanban_column_name_per_board'), postgresql_ignore_search_path=False ) op.create_table('kanban_card', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('title', sa.VARCHAR(length=200), autoincrement=False, nullable=False), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('position', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('color', sa.VARCHAR(length=7), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('column_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('project_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('task_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('assigned_to_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('due_date', sa.DATE(), autoincrement=False, nullable=True), sa.Column('completed_date', sa.DATE(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['assigned_to_id'], ['user.id'], name=op.f('kanban_card_assigned_to_id_fkey')), sa.ForeignKeyConstraint(['column_id'], ['kanban_column.id'], name=op.f('kanban_card_column_id_fkey')), sa.ForeignKeyConstraint(['created_by_id'], ['user.id'], name=op.f('kanban_card_created_by_id_fkey')), sa.ForeignKeyConstraint(['project_id'], ['project.id'], name=op.f('kanban_card_project_id_fkey')), sa.ForeignKeyConstraint(['task_id'], ['task.id'], name=op.f('kanban_card_task_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('kanban_card_pkey')) ) # ### end Alembic commands ###