-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add migration script to make User.active not-nullable
- Loading branch information
1 parent
3ecd0f4
commit 27c5d74
Showing
4 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
migrations/versions/3a5712474808_make_user_active_field_non_nullable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Make User.active field non nullable | ||
Revision ID: 3a5712474808 | ||
Revises: 9b3a5a7145d7 | ||
Create Date: 2024-11-08 22:00:41.161934 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "3a5712474808" # pragma: allowlist secret | ||
down_revision = "9b3a5a7145d7" # pragma: allowlist secret | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute('UPDATE "User" SET active = True WHERE active IS NULL') | ||
op.alter_column("User", "active", nullable=False, server_default="True") | ||
|
||
|
||
def downgrade(): | ||
op.alter_column("User", "active", nullable=True, server_default=None) | ||
op.execute('UPDATE "User" SET active = NULL WHERE active = True') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters