|
| 1 | +"""user data |
| 2 | +
|
| 3 | +Revision ID: 1d9dc121301b |
| 4 | +Revises: 1f43c69cbade |
| 5 | +Create Date: 2026-03-11 00:22:17.807587 |
| 6 | +
|
| 7 | +""" |
| 8 | +from typing import Sequence, Union |
| 9 | + |
| 10 | +from alembic import op |
| 11 | +import sqlalchemy as sa |
| 12 | + |
| 13 | + |
| 14 | +# revision identifiers, used by Alembic. |
| 15 | +revision: str = '1d9dc121301b' |
| 16 | +down_revision: Union[str, Sequence[str], None] = '1f43c69cbade' |
| 17 | +branch_labels: Union[str, Sequence[str], None] = None |
| 18 | +depends_on: Union[str, Sequence[str], None] = None |
| 19 | + |
| 20 | + |
| 21 | +def upgrade() -> None: |
| 22 | + """Upgrade schema.""" |
| 23 | + # ### commands auto generated by Alembic - please adjust! ### |
| 24 | + op.drop_index(op.f('idx_categories_group_id'), table_name='categories') |
| 25 | + op.drop_constraint(op.f('document_files_document_id_fkey'), 'document_files', type_='foreignkey') |
| 26 | + op.create_foreign_key(None, 'document_files', 'documents', ['document_id'], ['id']) |
| 27 | + op.drop_constraint(op.f('document_tags_tag_id_fkey'), 'document_tags', type_='foreignkey') |
| 28 | + op.drop_constraint(op.f('document_tags_document_id_fkey'), 'document_tags', type_='foreignkey') |
| 29 | + op.create_foreign_key(None, 'document_tags', 'tags', ['tag_id'], ['id']) |
| 30 | + op.create_foreign_key(None, 'document_tags', 'documents', ['document_id'], ['id']) |
| 31 | + op.drop_index(op.f('idx_documents_category_id'), table_name='documents') |
| 32 | + op.drop_index(op.f('idx_documents_code_trgm'), table_name='documents', postgresql_ops={'code': 'gin_trgm_ops'}, postgresql_using='gin') |
| 33 | + op.drop_index(op.f('idx_documents_name_trgm'), table_name='documents', postgresql_ops={'name': 'gin_trgm_ops'}, postgresql_using='gin') |
| 34 | + op.drop_index(op.f('idx_pages_designation_trgm'), table_name='pages', postgresql_ops={'designation': 'gin_trgm_ops'}, postgresql_using='gin') |
| 35 | + op.drop_index(op.f('idx_pages_document_id'), table_name='pages') |
| 36 | + op.drop_index(op.f('idx_pages_name_trgm'), table_name='pages', postgresql_ops={'name': 'gin_trgm_ops'}, postgresql_using='gin') |
| 37 | + op.add_column('users', sa.Column('department_id', sa.Integer(), nullable=True)) |
| 38 | + op.create_foreign_key(None, 'users', 'groups', ['department_id'], ['id']) |
| 39 | + op.drop_column('users', 'department') |
| 40 | + # ### end Alembic commands ### |
| 41 | + |
| 42 | + |
| 43 | +def downgrade() -> None: |
| 44 | + """Downgrade schema.""" |
| 45 | + # ### commands auto generated by Alembic - please adjust! ### |
| 46 | + op.add_column('users', sa.Column('department', sa.VARCHAR(length=100), autoincrement=False, nullable=True)) |
| 47 | + op.drop_constraint(None, 'users', type_='foreignkey') |
| 48 | + op.drop_column('users', 'department_id') |
| 49 | + op.create_index(op.f('idx_pages_name_trgm'), 'pages', ['name'], unique=False, postgresql_ops={'name': 'gin_trgm_ops'}, postgresql_using='gin') |
| 50 | + op.create_index(op.f('idx_pages_document_id'), 'pages', ['document_id'], unique=False) |
| 51 | + op.create_index(op.f('idx_pages_designation_trgm'), 'pages', ['designation'], unique=False, postgresql_ops={'designation': 'gin_trgm_ops'}, postgresql_using='gin') |
| 52 | + op.create_index(op.f('idx_documents_name_trgm'), 'documents', ['name'], unique=False, postgresql_ops={'name': 'gin_trgm_ops'}, postgresql_using='gin') |
| 53 | + op.create_index(op.f('idx_documents_code_trgm'), 'documents', ['code'], unique=False, postgresql_ops={'code': 'gin_trgm_ops'}, postgresql_using='gin') |
| 54 | + op.create_index(op.f('idx_documents_category_id'), 'documents', ['category_id'], unique=False) |
| 55 | + op.drop_constraint(None, 'document_tags', type_='foreignkey') |
| 56 | + op.drop_constraint(None, 'document_tags', type_='foreignkey') |
| 57 | + op.create_foreign_key(op.f('document_tags_document_id_fkey'), 'document_tags', 'documents', ['document_id'], ['id'], ondelete='CASCADE') |
| 58 | + op.create_foreign_key(op.f('document_tags_tag_id_fkey'), 'document_tags', 'tags', ['tag_id'], ['id'], ondelete='CASCADE') |
| 59 | + op.drop_constraint(None, 'document_files', type_='foreignkey') |
| 60 | + op.create_foreign_key(op.f('document_files_document_id_fkey'), 'document_files', 'documents', ['document_id'], ['id'], ondelete='CASCADE') |
| 61 | + op.create_index(op.f('idx_categories_group_id'), 'categories', ['group_id'], unique=False) |
| 62 | + # ### end Alembic commands ### |
0 commit comments