|
| 1 | +"""Remove refinery token table |
| 2 | +
|
| 3 | +Revision ID: 414c990688f3 |
| 4 | +Revises: 3e59ce51739c |
| 5 | +Create Date: 2024-09-09 09:25:36.796509 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | +from sqlalchemy.dialects import postgresql |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = '414c990688f3' |
| 14 | +down_revision = '3e59ce51739c' |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + # generated code |
| 22 | + op.drop_index('ix_personal_access_token_project_id', table_name='personal_access_token') |
| 23 | + op.drop_index('ix_personal_access_token_user_id', table_name='personal_access_token') |
| 24 | + op.drop_table('personal_access_token') |
| 25 | + |
| 26 | + op.drop_index('ix_cognition_project_refinery_question_project_id', table_name='project', schema='cognition') |
| 27 | + op.drop_index('ix_cognition_project_refinery_references_project_id', table_name='project', schema='cognition') |
| 28 | + op.drop_index('ix_cognition_project_refinery_relevance_project_id', table_name='project', schema='cognition') |
| 29 | + op.drop_constraint('project_refinery_references_project_id_fkey', 'project', schema='cognition', type_='foreignkey') |
| 30 | + op.drop_constraint('project_refinery_question_project_id_fkey', 'project', schema='cognition', type_='foreignkey') |
| 31 | + op.drop_constraint('project_refinery_relevance_project_id_fkey', 'project', schema='cognition', type_='foreignkey') |
| 32 | + op.drop_column('project', 'refinery_references_project_id', schema='cognition') |
| 33 | + op.drop_column('project', 'refinery_synchronization_interval_option', schema='cognition') |
| 34 | + op.drop_column('project', 'refinery_question_project_id', schema='cognition') |
| 35 | + op.drop_column('project', 'refinery_relevance_project_id', schema='cognition') |
| 36 | + op.drop_column('project', 'execute_query_enrichment_if_source_code', schema='cognition') |
| 37 | + |
| 38 | + op.drop_index('ix_cognition_refinery_synchronization_task_cognition_project_id', table_name='refinery_synchronization_task', schema='cognition') |
| 39 | + op.drop_index('ix_cognition_refinery_synchronization_task_created_by', table_name='refinery_synchronization_task', schema='cognition') |
| 40 | + op.drop_index('ix_cognition_refinery_synchronization_task_refinery_project_id', table_name='refinery_synchronization_task', schema='cognition') |
| 41 | + op.drop_table('refinery_synchronization_task', schema='cognition') |
| 42 | + |
| 43 | + # ### end Alembic commands ### |
| 44 | + |
| 45 | + |
| 46 | +def downgrade(): |
| 47 | + # ### commands auto generated by Alembic - please adjust! ### |
| 48 | + |
| 49 | + # ------------------------ pat remove ------------------------ |
| 50 | + op.create_table('personal_access_token', |
| 51 | + sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), |
| 52 | + sa.Column('project_id', postgresql.UUID(), autoincrement=False, nullable=True), |
| 53 | + sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=True), |
| 54 | + sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True), |
| 55 | + sa.Column('scope', sa.VARCHAR(), autoincrement=False, nullable=True), |
| 56 | + sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), |
| 57 | + sa.Column('expires_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), |
| 58 | + sa.Column('last_used', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), |
| 59 | + sa.Column('token', sa.VARCHAR(), autoincrement=False, nullable=True), |
| 60 | + sa.ForeignKeyConstraint(['project_id'], ['project.id'], name='personal_access_token_project_id_fkey', ondelete='CASCADE'), |
| 61 | + sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='personal_access_token_user_id_fkey', ondelete='CASCADE'), |
| 62 | + sa.PrimaryKeyConstraint('id', name='personal_access_token_pkey') |
| 63 | + ) |
| 64 | + op.create_index('ix_personal_access_token_user_id', 'personal_access_token', ['user_id'], unique=False) |
| 65 | + op.create_index('ix_personal_access_token_project_id', 'personal_access_token', ['project_id'], unique=False) |
| 66 | + |
| 67 | + # ------------------------ cognition table fields ------------------------ |
| 68 | + |
| 69 | + op.add_column('project', sa.Column('execute_query_enrichment_if_source_code', sa.VARCHAR(), autoincrement=False, nullable=True), schema='cognition') |
| 70 | + op.add_column('project', sa.Column('refinery_relevance_project_id', postgresql.UUID(), autoincrement=False, nullable=True), schema='cognition') |
| 71 | + op.add_column('project', sa.Column('refinery_question_project_id', postgresql.UUID(), autoincrement=False, nullable=True), schema='cognition') |
| 72 | + op.add_column('project', sa.Column('refinery_synchronization_interval_option', sa.VARCHAR(), autoincrement=False, nullable=True), schema='cognition') |
| 73 | + op.add_column('project', sa.Column('refinery_references_project_id', postgresql.UUID(), autoincrement=False, nullable=True), schema='cognition') |
| 74 | + op.create_foreign_key('project_refinery_relevance_project_id_fkey', 'project', 'project', ['refinery_relevance_project_id'], ['id'], source_schema='cognition', ondelete='SET NULL') |
| 75 | + op.create_foreign_key('project_refinery_question_project_id_fkey', 'project', 'project', ['refinery_question_project_id'], ['id'], source_schema='cognition', ondelete='SET NULL') |
| 76 | + op.create_foreign_key('project_refinery_references_project_id_fkey', 'project', 'project', ['refinery_references_project_id'], ['id'], source_schema='cognition', ondelete='SET NULL') |
| 77 | + op.create_index('ix_cognition_project_refinery_relevance_project_id', 'project', ['refinery_relevance_project_id'], unique=False, schema='cognition') |
| 78 | + op.create_index('ix_cognition_project_refinery_references_project_id', 'project', ['refinery_references_project_id'], unique=False, schema='cognition') |
| 79 | + op.create_index('ix_cognition_project_refinery_question_project_id', 'project', ['refinery_question_project_id'], unique=False, schema='cognition') |
| 80 | + |
| 81 | + # ------------------------ sync table ------------------------ |
| 82 | + |
| 83 | + op.create_table('refinery_synchronization_task', |
| 84 | + sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False), |
| 85 | + sa.Column('cognition_project_id', postgresql.UUID(), autoincrement=False, nullable=True), |
| 86 | + sa.Column('refinery_project_id', postgresql.UUID(), autoincrement=False, nullable=True), |
| 87 | + sa.Column('created_by', postgresql.UUID(), autoincrement=False, nullable=True), |
| 88 | + sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), |
| 89 | + sa.Column('finished_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), |
| 90 | + sa.Column('state', sa.VARCHAR(), autoincrement=False, nullable=True), |
| 91 | + sa.Column('logs', postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=True), |
| 92 | + sa.Column('num_records_created', sa.INTEGER(), autoincrement=False, nullable=True), |
| 93 | + sa.ForeignKeyConstraint(['cognition_project_id'], ['cognition.project.id'], name='refinery_synchronization_task_cognition_project_id_fkey', ondelete='CASCADE'), |
| 94 | + sa.ForeignKeyConstraint(['created_by'], ['user.id'], name='refinery_synchronization_task_created_by_fkey', ondelete='CASCADE'), |
| 95 | + sa.ForeignKeyConstraint(['refinery_project_id'], ['project.id'], name='refinery_synchronization_task_refinery_project_id_fkey', ondelete='CASCADE'), |
| 96 | + sa.PrimaryKeyConstraint('id', name='refinery_synchronization_task_pkey'), |
| 97 | + schema='cognition' |
| 98 | + ) |
| 99 | + op.create_index('ix_cognition_refinery_synchronization_task_refinery_project_id', 'refinery_synchronization_task', ['refinery_project_id'], unique=False, schema='cognition') |
| 100 | + op.create_index('ix_cognition_refinery_synchronization_task_created_by', 'refinery_synchronization_task', ['created_by'], unique=False, schema='cognition') |
| 101 | + op.create_index('ix_cognition_refinery_synchronization_task_cognition_project_id', 'refinery_synchronization_task', ['cognition_project_id'], unique=False, schema='cognition') |
| 102 | + |
| 103 | + # ### end Alembic commands ### |
0 commit comments