refactor: moving more models to mapped_column
This commit is contained in:
parent
ea020d6edd
commit
75b2c1adf0
9 changed files with 272 additions and 94 deletions
124
migrations/versions/13b1d64f134a_enforce_not_null_restrctions.py
Normal file
124
migrations/versions/13b1d64f134a_enforce_not_null_restrctions.py
Normal file
|
@ -0,0 +1,124 @@
|
|||
"""enforce not null restrctions
|
||||
|
||||
Revision ID: 13b1d64f134a
|
||||
Revises: bbec86de37c4
|
||||
Create Date: 2024-11-10 15:12:16.589705
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import sqlite
|
||||
|
||||
revision = '13b1d64f134a'
|
||||
down_revision = 'bbec86de37c4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('bridge_conf', schema=None) as batch_op:
|
||||
batch_op.alter_column('target_number',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('max_number',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('expiry_hours',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('provider_allocation',
|
||||
existing_type=sa.VARCHAR(length=6),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('cloud_account', schema=None) as batch_op:
|
||||
batch_op.alter_column('provider',
|
||||
existing_type=sa.VARCHAR(length=10),
|
||||
nullable=False)
|
||||
batch_op.alter_column('credentials',
|
||||
existing_type=sqlite.JSON(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('enabled',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('max_distributions',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('max_sub_distributions',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
batch_op.alter_column('max_instances',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('deprecation', schema=None) as batch_op:
|
||||
batch_op.alter_column('resource_type',
|
||||
existing_type=sa.VARCHAR(length=50),
|
||||
nullable=False)
|
||||
batch_op.alter_column('resource_id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('group', schema=None) as batch_op:
|
||||
batch_op.alter_column('eotk',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=False)
|
||||
|
||||
with op.batch_alter_table('terraform_state', schema=None) as batch_op:
|
||||
batch_op.alter_column('state',
|
||||
existing_type=sa.VARCHAR(),
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('terraform_state', schema=None) as batch_op:
|
||||
batch_op.alter_column('state',
|
||||
existing_type=sa.VARCHAR(),
|
||||
nullable=True)
|
||||
|
||||
with op.batch_alter_table('group', schema=None) as batch_op:
|
||||
batch_op.alter_column('eotk',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=True)
|
||||
|
||||
with op.batch_alter_table('deprecation', schema=None) as batch_op:
|
||||
batch_op.alter_column('resource_id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('resource_type',
|
||||
existing_type=sa.VARCHAR(length=50),
|
||||
nullable=True)
|
||||
|
||||
with op.batch_alter_table('cloud_account', schema=None) as batch_op:
|
||||
batch_op.alter_column('max_instances',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('max_sub_distributions',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('max_distributions',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('enabled',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('credentials',
|
||||
existing_type=sqlite.JSON(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('provider',
|
||||
existing_type=sa.VARCHAR(length=10),
|
||||
nullable=True)
|
||||
|
||||
with op.batch_alter_table('bridge_conf', schema=None) as batch_op:
|
||||
batch_op.alter_column('provider_allocation',
|
||||
existing_type=sa.VARCHAR(length=6),
|
||||
nullable=True)
|
||||
batch_op.alter_column('expiry_hours',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('max_number',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
batch_op.alter_column('target_number',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
Loading…
Add table
Add a link
Reference in a new issue