Skip to content

Commit 4304cc6

Browse files
committed
Migration: backfill last_streak in users to be nullable False
1 parent aba9db7 commit 4304cc6

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""make last_streak non_null default 0
2+
3+
Revision ID: 46ba03c28573
4+
Revises: b09a4d8151d6
5+
Create Date: 2026-03-06 01:47:07.348774
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '46ba03c28573'
14+
down_revision = 'b09a4d8151d6'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
op.execute("UPDATE users SET last_streak = 0 WHERE last_streak IS NULL")
21+
op.alter_column('users', 'last_streak',
22+
existing_type=sa.INTEGER(),
23+
nullable=False,
24+
server_default=sa.text('0')
25+
)
26+
27+
28+
def downgrade():
29+
op.alter_column('users', 'last_streak',
30+
existing_type=sa.INTEGER(),
31+
nullable=True,
32+
server_default=None
33+
)

0 commit comments

Comments
 (0)