diff --git a/migrations/public/versions/b853a06f4bf4_language_llm_fields_added.py b/migrations/public/versions/b853a06f4bf4_language_llm_fields_added.py new file mode 100644 index 0000000..52dceec --- /dev/null +++ b/migrations/public/versions/b853a06f4bf4_language_llm_fields_added.py @@ -0,0 +1,62 @@ +"""Language & LLM fields added + +Revision ID: b853a06f4bf4 +Revises: 08e334d64cab +Create Date: 2024-05-01 09:46:02.013322 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'b853a06f4bf4' +down_revision = '08e334d64cab' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint('roles_users_role_id_fkey', type_='foreignkey') + batch_op.drop_constraint('roles_users_user_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'], referent_schema='public', ondelete='CASCADE') + batch_op.create_foreign_key(None, 'role', ['role_id'], ['id'], referent_schema='public', ondelete='CASCADE') + + with op.batch_alter_table('tenant', schema=None) as batch_op: + batch_op.add_column(sa.Column('default_language', sa.String(length=2), nullable=True)) + batch_op.add_column(sa.Column('allowed_languages', postgresql.ARRAY(sa.String(length=2)), nullable=True)) + batch_op.add_column(sa.Column('default_embedding_model', sa.String(length=50), nullable=True)) + batch_op.add_column(sa.Column('allowed_embedding_models', postgresql.ARRAY(sa.String(length=50)), nullable=True)) + batch_op.add_column(sa.Column('default_llm_model', sa.String(length=50), nullable=True)) + batch_op.add_column(sa.Column('allowed_llm_models', postgresql.ARRAY(sa.String(length=50)), nullable=True)) + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_tenant_id_fkey', type_='foreignkey') + batch_op.create_foreign_key(None, 'tenant', ['tenant_id'], ['id'], referent_schema='public') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('user_tenant_id_fkey', 'tenant', ['tenant_id'], ['id']) + + with op.batch_alter_table('tenant', schema=None) as batch_op: + batch_op.drop_column('allowed_llm_models') + batch_op.drop_column('default_llm_model') + batch_op.drop_column('allowed_embedding_models') + batch_op.drop_column('default_embedding_model') + batch_op.drop_column('allowed_languages') + batch_op.drop_column('default_language') + + with op.batch_alter_table('roles_users', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.create_foreign_key('roles_users_user_id_fkey', 'user', ['user_id'], ['id'], ondelete='CASCADE') + batch_op.create_foreign_key('roles_users_role_id_fkey', 'role', ['role_id'], ['id'], ondelete='CASCADE') + + # ### end Alembic commands ### diff --git a/migrations/tenant/versions/45620002ae0d_additional_processing_fields_added_to_.py b/migrations/tenant/versions/45620002ae0d_additional_processing_fields_added_to_.py new file mode 100644 index 0000000..f7c05a8 --- /dev/null +++ b/migrations/tenant/versions/45620002ae0d_additional_processing_fields_added_to_.py @@ -0,0 +1,34 @@ +"""Additional processing fields added to the model + +Revision ID: 45620002ae0d +Revises: 4f22dd6260e3 +Create Date: 2024-05-01 21:55:26.729666 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '45620002ae0d' +down_revision = '4f22dd6260e3' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('document_version', sa.Column('processing', sa.Boolean(), nullable=False)) + op.add_column('document_version', sa.Column('processing_started_at', sa.DateTime(), nullable=True)) + op.add_column('document_version', sa.Column('processing_finished_at', sa.DateTime(), nullable=True)) + op.add_column('document_version', sa.Column('processing_error', sa.String(length=255), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('document_version', 'processing_error') + op.drop_column('document_version', 'processing_finished_at') + op.drop_column('document_version', 'processing_started_at') + op.drop_column('document_version', 'processing') + # ### end Alembic commands ###