|
| 1 | +# flake8: noqa |
| 2 | +""" |
| 3 | +
|
| 4 | +DB setup 6.x |
| 5 | +
|
| 6 | +Revision ID: 83993fcdf5ef |
| 7 | +Revises: cd8b7108713a |
| 8 | +Create Date: 2021-10-04 09:22:36.987652 |
| 9 | +
|
| 10 | +""" |
| 11 | +from alembic import op |
| 12 | +import sqlalchemy as sa |
| 13 | + |
| 14 | + |
| 15 | +# revision identifiers, used by Alembic. |
| 16 | +revision = '83993fcdf5ef' |
| 17 | +down_revision = 'cd8b7108713a' |
| 18 | +branch_labels = None |
| 19 | +depends_on = None |
| 20 | + |
| 21 | + |
| 22 | +def upgrade(): |
| 23 | + # ### commands auto generated by Alembic - please adjust! ### |
| 24 | + op.create_table('operations', |
| 25 | + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), |
| 26 | + sa.Column('path', sa.String(length=255), nullable=True), |
| 27 | + sa.Column('category', sa.String(length=255), nullable=True), |
| 28 | + sa.Column('description', sa.String(length=255), nullable=True), |
| 29 | + sa.PrimaryKeyConstraint('id'), |
| 30 | + sa.UniqueConstraint('path') |
| 31 | + ) |
| 32 | + op.drop_table('projects') |
| 33 | + with op.batch_alter_table('changes', schema=None) as batch_op: |
| 34 | + batch_op.add_column(sa.Column('op_id', sa.Integer(), nullable=True)) |
| 35 | + batch_op.drop_constraint(None, type_='foreignkey') |
| 36 | + batch_op.create_foreign_key(None, 'operations', ['op_id'], ['id']) |
| 37 | + batch_op.drop_column('p_id') |
| 38 | + |
| 39 | + with op.batch_alter_table('messages', schema=None) as batch_op: |
| 40 | + batch_op.add_column(sa.Column('op_id', sa.Integer(), nullable=True)) |
| 41 | + batch_op.drop_constraint(None, type_='foreignkey') |
| 42 | + batch_op.create_foreign_key(None, 'operations', ['op_id'], ['id']) |
| 43 | + batch_op.drop_column('p_id') |
| 44 | + |
| 45 | + with op.batch_alter_table('permissions', schema=None) as batch_op: |
| 46 | + batch_op.add_column(sa.Column('op_id', sa.Integer(), nullable=True)) |
| 47 | + batch_op.drop_constraint(None, type_='foreignkey') |
| 48 | + batch_op.create_foreign_key(None, 'operations', ['op_id'], ['id']) |
| 49 | + batch_op.drop_column('p_id') |
| 50 | + |
| 51 | + with op.batch_alter_table('users', schema=None) as batch_op: |
| 52 | + batch_op.add_column(sa.Column('registered_on', sa.DateTime(), nullable=False)) |
| 53 | + batch_op.add_column(sa.Column('confirmed', sa.Boolean(), nullable=False)) |
| 54 | + batch_op.add_column(sa.Column('confirmed_on', sa.DateTime(), nullable=True)) |
| 55 | + |
| 56 | + # ### end Alembic commands ### |
| 57 | + |
| 58 | + |
| 59 | +def downgrade(): |
| 60 | + # ### commands auto generated by Alembic - please adjust! ### |
| 61 | + with op.batch_alter_table('users', schema=None) as batch_op: |
| 62 | + batch_op.drop_column('confirmed_on') |
| 63 | + batch_op.drop_column('confirmed') |
| 64 | + batch_op.drop_column('registered_on') |
| 65 | + |
| 66 | + with op.batch_alter_table('permissions', schema=None) as batch_op: |
| 67 | + batch_op.add_column(sa.Column('p_id', sa.INTEGER(), nullable=True)) |
| 68 | + batch_op.drop_constraint(None, type_='foreignkey') |
| 69 | + batch_op.create_foreign_key(None, 'projects', ['p_id'], ['id']) |
| 70 | + batch_op.drop_column('op_id') |
| 71 | + |
| 72 | + with op.batch_alter_table('messages', schema=None) as batch_op: |
| 73 | + batch_op.add_column(sa.Column('p_id', sa.INTEGER(), nullable=True)) |
| 74 | + batch_op.drop_constraint(None, type_='foreignkey') |
| 75 | + batch_op.create_foreign_key(None, 'projects', ['p_id'], ['id']) |
| 76 | + batch_op.drop_column('op_id') |
| 77 | + |
| 78 | + with op.batch_alter_table('changes', schema=None) as batch_op: |
| 79 | + batch_op.add_column(sa.Column('p_id', sa.INTEGER(), nullable=True)) |
| 80 | + batch_op.drop_constraint(None, type_='foreignkey') |
| 81 | + batch_op.create_foreign_key(None, 'projects', ['p_id'], ['id']) |
| 82 | + batch_op.drop_column('op_id') |
| 83 | + |
| 84 | + op.create_table('projects', |
| 85 | + sa.Column('id', sa.INTEGER(), nullable=False), |
| 86 | + sa.Column('path', sa.VARCHAR(length=255), nullable=True), |
| 87 | + sa.Column('description', sa.VARCHAR(length=255), nullable=True), |
| 88 | + sa.PrimaryKeyConstraint('id'), |
| 89 | + sa.UniqueConstraint('path') |
| 90 | + ) |
| 91 | + op.drop_table('operations') |
| 92 | + # ### end Alembic commands ### |
0 commit comments