|
| 1 | +"""Adjust position titles |
| 2 | +
|
| 3 | +Revision ID: c42e6b5815dd |
| 4 | +Revises: b888e97fd66e |
| 5 | +Create Date: 2025-01-24 09:44:13.649781 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from alembic import op |
| 10 | +import sqlalchemy as sa |
| 11 | +from sqlalchemy.dialects import postgresql |
| 12 | + |
| 13 | +# revision identifiers, used by Alembic. |
| 14 | +revision = "c42e6b5815dd" |
| 15 | +down_revision = "b888e97fd66e" |
| 16 | +branch_labels = None |
| 17 | +depends_on = None |
| 18 | + |
| 19 | + |
| 20 | +def upgrade(): |
| 21 | + # ### commands auto generated by Alembic - please adjust! ### |
| 22 | + op.drop_table("projects_version") |
| 23 | + op.execute( |
| 24 | + f"UPDATE positions set name='Deputy Director, Compliance & Enforcement Operations' WHERE name='Deputy Director Operations'" |
| 25 | + ) |
| 26 | + op.execute( |
| 27 | + f"UPDATE positions set name='Director, Compliance & Enforcement' WHERE name='Director'" |
| 28 | + ) |
| 29 | + op.execute( |
| 30 | + f"INSERT INTO positions(name, description, created_date, created_by) VALUES ('Compliance & Enforcement Specialist','Compliance & Enforcement Specialist',now() at time zone 'utc','system')" |
| 31 | + ) |
| 32 | + op.execute( |
| 33 | + f"INSERT INTO positions(name, description, created_date, created_by) VALUES ('Other','Other',now() at time zone 'utc','system')" |
| 34 | + ) |
| 35 | + # ### end Alembic commands ### |
| 36 | + |
| 37 | + |
| 38 | +def downgrade(): |
| 39 | + # ### commands auto generated by Alembic - please adjust! ### |
| 40 | + op.execute( |
| 41 | + f"UPDATE positions set name='Deputy Director Operations' WHERE name='Deputy Director, Compliance & Enforcement Operations'" |
| 42 | + ) |
| 43 | + op.execute( |
| 44 | + f"UPDATE positions set name='Director' WHERE name='Director, Compliance & Enforcement'" |
| 45 | + ) |
| 46 | + op.execute( |
| 47 | + f"DELETE FROM positions WHERE name='Compliance & Enforcement Specialist'" |
| 48 | + ) |
| 49 | + op.execute(f"DELETE FROM positions WHERE name='Other'") |
| 50 | + |
| 51 | + op.create_table( |
| 52 | + "projects_version", |
| 53 | + sa.Column("id", sa.INTEGER(), autoincrement=False, nullable=False), |
| 54 | + sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True), |
| 55 | + sa.Column( |
| 56 | + "created_date", postgresql.TIMESTAMP(), autoincrement=False, nullable=True |
| 57 | + ), |
| 58 | + sa.Column( |
| 59 | + "updated_date", postgresql.TIMESTAMP(), autoincrement=False, nullable=True |
| 60 | + ), |
| 61 | + sa.Column( |
| 62 | + "created_by", sa.VARCHAR(length=100), autoincrement=False, nullable=True |
| 63 | + ), |
| 64 | + sa.Column( |
| 65 | + "updated_by", sa.VARCHAR(length=100), autoincrement=False, nullable=True |
| 66 | + ), |
| 67 | + sa.Column( |
| 68 | + "is_active", |
| 69 | + sa.BOOLEAN(), |
| 70 | + server_default=sa.text("true"), |
| 71 | + autoincrement=False, |
| 72 | + nullable=True, |
| 73 | + ), |
| 74 | + sa.Column( |
| 75 | + "is_deleted", |
| 76 | + sa.BOOLEAN(), |
| 77 | + server_default=sa.text("false"), |
| 78 | + autoincrement=False, |
| 79 | + nullable=True, |
| 80 | + ), |
| 81 | + sa.Column("transaction_id", sa.BIGINT(), autoincrement=False, nullable=False), |
| 82 | + sa.Column( |
| 83 | + "end_transaction_id", sa.BIGINT(), autoincrement=False, nullable=True |
| 84 | + ), |
| 85 | + sa.Column("operation_type", sa.SMALLINT(), autoincrement=False, nullable=False), |
| 86 | + sa.Column( |
| 87 | + "name_mod", |
| 88 | + sa.BOOLEAN(), |
| 89 | + server_default=sa.text("false"), |
| 90 | + autoincrement=False, |
| 91 | + nullable=False, |
| 92 | + ), |
| 93 | + sa.Column( |
| 94 | + "created_date_mod", |
| 95 | + sa.BOOLEAN(), |
| 96 | + server_default=sa.text("false"), |
| 97 | + autoincrement=False, |
| 98 | + nullable=False, |
| 99 | + ), |
| 100 | + sa.Column( |
| 101 | + "updated_date_mod", |
| 102 | + sa.BOOLEAN(), |
| 103 | + server_default=sa.text("false"), |
| 104 | + autoincrement=False, |
| 105 | + nullable=False, |
| 106 | + ), |
| 107 | + sa.Column( |
| 108 | + "created_by_mod", |
| 109 | + sa.BOOLEAN(), |
| 110 | + server_default=sa.text("false"), |
| 111 | + autoincrement=False, |
| 112 | + nullable=False, |
| 113 | + ), |
| 114 | + sa.Column( |
| 115 | + "updated_by_mod", |
| 116 | + sa.BOOLEAN(), |
| 117 | + server_default=sa.text("false"), |
| 118 | + autoincrement=False, |
| 119 | + nullable=False, |
| 120 | + ), |
| 121 | + sa.Column( |
| 122 | + "is_active_mod", |
| 123 | + sa.BOOLEAN(), |
| 124 | + server_default=sa.text("false"), |
| 125 | + autoincrement=False, |
| 126 | + nullable=False, |
| 127 | + ), |
| 128 | + sa.Column( |
| 129 | + "is_deleted_mod", |
| 130 | + sa.BOOLEAN(), |
| 131 | + server_default=sa.text("false"), |
| 132 | + autoincrement=False, |
| 133 | + nullable=False, |
| 134 | + ), |
| 135 | + sa.PrimaryKeyConstraint("id", "transaction_id", name="projects_version_pkey"), |
| 136 | + ) |
| 137 | + with op.batch_alter_table("projects_version", schema=None) as batch_op: |
| 138 | + batch_op.create_index( |
| 139 | + "ix_projects_version_transaction_id", ["transaction_id"], unique=False |
| 140 | + ) |
| 141 | + batch_op.create_index( |
| 142 | + "ix_projects_version_operation_type", ["operation_type"], unique=False |
| 143 | + ) |
| 144 | + batch_op.create_index( |
| 145 | + "ix_projects_version_end_transaction_id", |
| 146 | + ["end_transaction_id"], |
| 147 | + unique=False, |
| 148 | + ) |
| 149 | + |
| 150 | + # ### end Alembic commands ### |
0 commit comments