Skip to content

Commit

Permalink
Make extra non-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ajay committed Dec 2, 2021
1 parent 2098786 commit ddac85c
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,23 @@
down_revision = "aea15018d53b"

import sqlalchemy as sa
from sqlalchemy.sql import table, column
from sqlalchemy import String

from alembic import op
from sqlalchemy import String
from sqlalchemy.sql import column, table

connection = op.get_bind()

report_schedule = table("report_schedule", column("extra", String))


def upgrade():
op.add_column(
"report_schedule",
sa.Column(
"extra",
sa.Text(),
nullable=True,
default="{}",
),
)
connection.execute(report_schedule.update().values({"extra": "{}"}))
with op.batch_alter_table("report_schedule") as batch_op:
op.add_column(
"report_schedule",
sa.Column("extra", sa.Text(), nullable=True, default="{}",),
)
connection.execute(report_schedule.update().values({"extra": "{}"}))
batch_op.alter_column("extra", existing_type=sa.Text(), nullabe=False)


def downgrade():
Expand Down

0 comments on commit ddac85c

Please sign in to comment.