Skip to content

Commit 129e81e

Browse files
fix: use default null for from_address in migration
1 parent 735df9f commit 129e81e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

migrations/versions/c563e06b01b3_add_sender_email_in_emailnotification.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,23 @@
2121

2222
def upgrade() -> None:
2323
# ### commands auto generated by Alembic - please adjust! ###
24-
op.add_column('emailnotification', sa.Column('from_address', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
24+
op.add_column(
25+
"emailnotification",
26+
sa.Column(
27+
"from_address",
28+
sqlmodel.sql.sqltypes.AutoString(),
29+
nullable=True,
30+
server_default="",
31+
),
32+
)
33+
op.execute(sa.text("UPDATE emailnotification SET from_address = '' WHERE from_address IS NULL"))
34+
op.alter_column(
35+
"emailnotification",
36+
"from_address",
37+
existing_type=sqlmodel.sql.sqltypes.AutoString(),
38+
nullable=False,
39+
server_default=None,
40+
)
2541
op.create_index(op.f('ix_emailnotification_from_address'), 'emailnotification', ['from_address'], unique=False)
2642
# ### end Alembic commands ###
2743

0 commit comments

Comments
 (0)