|
| 1 | +"""Default migration message |
| 2 | +
|
| 3 | +Revision ID: 9730c55381f3 |
| 4 | +Revises: b8490e92310f |
| 5 | +Create Date: 2025-05-21 13:18:02.105223 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from typing import Sequence, Union |
| 10 | + |
| 11 | +from alembic import op |
| 12 | +import sqlalchemy as sa |
| 13 | +from alembic_postgresql_enum import TableReference |
| 14 | + |
| 15 | +from sqlalchemy import Text |
| 16 | +import app.db.types |
| 17 | + |
| 18 | +# revision identifiers, used by Alembic. |
| 19 | +revision: str = "9730c55381f3" |
| 20 | +down_revision: Union[str, None] = "b8490e92310f" |
| 21 | +branch_labels: Union[str, Sequence[str], None] = None |
| 22 | +depends_on: Union[str, Sequence[str], None] = None |
| 23 | + |
| 24 | + |
| 25 | +def upgrade() -> None: |
| 26 | + # ### commands auto generated by Alembic - please adjust! ### |
| 27 | + op.create_table( |
| 28 | + "validation_result", |
| 29 | + sa.Column("id", sa.Uuid(), nullable=False), |
| 30 | + sa.Column("passed", sa.Boolean(), nullable=False), |
| 31 | + sa.Column("name", sa.String(), nullable=False), |
| 32 | + sa.Column("validated_entity_id", sa.Uuid(), nullable=False), |
| 33 | + sa.ForeignKeyConstraint(["id"], ["entity.id"], name=op.f("fk_validation_result_id_entity")), |
| 34 | + sa.ForeignKeyConstraint( |
| 35 | + ["validated_entity_id"], |
| 36 | + ["entity.id"], |
| 37 | + name=op.f("fk_validation_result_validated_entity_id_entity"), |
| 38 | + ), |
| 39 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_validation_result")), |
| 40 | + ) |
| 41 | + op.create_index(op.f("ix_validation_result_name"), "validation_result", ["name"], unique=False) |
| 42 | + op.create_index( |
| 43 | + op.f("ix_validation_result_validated_entity_id"), |
| 44 | + "validation_result", |
| 45 | + ["validated_entity_id"], |
| 46 | + unique=False, |
| 47 | + ) |
| 48 | + op.sync_enum_values( |
| 49 | + enum_schema="public", |
| 50 | + enum_name="entitytype", |
| 51 | + new_values=[ |
| 52 | + "analysis_software_source_code", |
| 53 | + "brain_atlas", |
| 54 | + "emodel", |
| 55 | + "cell_composition", |
| 56 | + "experimental_bouton_density", |
| 57 | + "experimental_neuron_density", |
| 58 | + "experimental_synapses_per_connection", |
| 59 | + "memodel", |
| 60 | + "mesh", |
| 61 | + "me_type_density", |
| 62 | + "reconstruction_morphology", |
| 63 | + "electrical_cell_recording", |
| 64 | + "electrical_recording_stimulus", |
| 65 | + "single_neuron_simulation", |
| 66 | + "single_neuron_synaptome", |
| 67 | + "single_neuron_synaptome_simulation", |
| 68 | + "ion_channel_model", |
| 69 | + "subject", |
| 70 | + "validation_result", |
| 71 | + ], |
| 72 | + affected_columns=[ |
| 73 | + TableReference(table_schema="public", table_name="entity", column_name="type") |
| 74 | + ], |
| 75 | + enum_values_to_rename=[], |
| 76 | + ) |
| 77 | + # ### end Alembic commands ### |
| 78 | + |
| 79 | + |
| 80 | +def downgrade() -> None: |
| 81 | + # ### commands auto generated by Alembic - please adjust! ### |
| 82 | + op.sync_enum_values( |
| 83 | + enum_schema="public", |
| 84 | + enum_name="entitytype", |
| 85 | + new_values=[ |
| 86 | + "analysis_software_source_code", |
| 87 | + "brain_atlas", |
| 88 | + "emodel", |
| 89 | + "cell_composition", |
| 90 | + "experimental_bouton_density", |
| 91 | + "experimental_neuron_density", |
| 92 | + "experimental_synapses_per_connection", |
| 93 | + "memodel", |
| 94 | + "mesh", |
| 95 | + "me_type_density", |
| 96 | + "reconstruction_morphology", |
| 97 | + "electrical_cell_recording", |
| 98 | + "electrical_recording_stimulus", |
| 99 | + "single_neuron_simulation", |
| 100 | + "single_neuron_synaptome", |
| 101 | + "single_neuron_synaptome_simulation", |
| 102 | + "ion_channel_model", |
| 103 | + "subject", |
| 104 | + ], |
| 105 | + affected_columns=[ |
| 106 | + TableReference(table_schema="public", table_name="entity", column_name="type") |
| 107 | + ], |
| 108 | + enum_values_to_rename=[], |
| 109 | + ) |
| 110 | + op.drop_index(op.f("ix_validation_result_validated_entity_id"), table_name="validation_result") |
| 111 | + op.drop_index(op.f("ix_validation_result_name"), table_name="validation_result") |
| 112 | + op.drop_table("validation_result") |
| 113 | + # ### end Alembic commands ### |
0 commit comments