mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 12:49:48 -04:00
reformat
This commit is contained in:
@@ -9,25 +9,29 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0364_drop_old_column'
|
||||
down_revision = '0363_cancelled_by_api_key'
|
||||
revision = "0364_drop_old_column"
|
||||
down_revision = "0363_cancelled_by_api_key"
|
||||
|
||||
|
||||
def upgrade():
|
||||
# move data over
|
||||
op.execute("UPDATE broadcast_message SET created_by_api_key_id=api_key_id WHERE created_by_api_key_id IS NULL")
|
||||
op.execute(
|
||||
"UPDATE broadcast_message SET created_by_api_key_id=api_key_id WHERE created_by_api_key_id IS NULL"
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_broadcast_message_created_by_not_null",
|
||||
"broadcast_message",
|
||||
"created_by_id is not null or created_by_api_key_id is not null"
|
||||
"created_by_id is not null or created_by_api_key_id is not null",
|
||||
)
|
||||
op.drop_column('broadcast_message', 'api_key_id')
|
||||
op.drop_column("broadcast_message", "api_key_id")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.add_column('broadcast_message', sa.Column('api_key_id', postgresql.UUID(), autoincrement=False, nullable=True))
|
||||
op.execute("UPDATE broadcast_message SET api_key_id=created_by_api_key_id") # move data over
|
||||
op.drop_constraint(
|
||||
"ck_broadcast_message_created_by_not_null",
|
||||
"broadcast_message"
|
||||
op.add_column(
|
||||
"broadcast_message",
|
||||
sa.Column("api_key_id", postgresql.UUID(), autoincrement=False, nullable=True),
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE broadcast_message SET api_key_id=created_by_api_key_id"
|
||||
) # move data over
|
||||
op.drop_constraint("ck_broadcast_message_created_by_not_null", "broadcast_message")
|
||||
|
||||
Reference in New Issue
Block a user