Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migrations): db's other than sqlite #2276

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ def upgrade() -> None:
with op.batch_alter_table("provider", schema=None) as batch_op:
batch_op.alter_column("pulling_enabled", nullable=False)
else:
# Implementation for other databases
# PostgreSQL and other databases implementation
with op.batch_alter_table("provider", schema=None) as batch_op:
# 1. Add the column as nullable
batch_op.add_column(
sa.Column(
"pulling_enabled",
sa.Boolean(),
nullable=False,
server_default=sa.true(),
)
sa.Column("pulling_enabled", sa.Boolean(), nullable=True)
)
# 2. Set default value for existing rows
op.execute(
"UPDATE provider SET pulling_enabled = true WHERE pulling_enabled IS NULL"
)
# 3. Make it non-nullable
batch_op.alter_column(
"pulling_enabled", nullable=False, server_default=sa.true()
)


Expand Down
Loading