fix: boolean server_default must be 'false' not '0' for Postgres

PostgreSQL rejects BOOLEAN DEFAULT 0 (DatatypeMismatch: column ... is of type
boolean but default expression is of type integer). Migration 0008
(platform_settings.active) crashed the alembic upgrade run by the entrypoint,
which in turn crash-looped the worker. Migration 0011 (password_reset_tokens.
used) had the same latent bug and would have failed next.

Change the Boolean server_default from text('0') to text('false') in both
migrations and both ORM models so the DDL is valid on both PostgreSQL
(production) and SQLite (local/tests).

Verified: full 0001->0011 chain runs on fresh SQLite; alembic check reports no
drift; backend suite 201 passed.
This commit is contained in:
Kunthawat Greethong
2026-08-31 22:21:53 +07:00
parent 851ed65f45
commit e572bc910f
4 changed files with 4 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ def upgrade() -> None:
sa.Column("settings", sa.JSON(), nullable=True),
sa.Column("secret_ref", sa.String(length=512), nullable=True),
sa.Column("updated_by_user_id", sa.String(length=64), nullable=True),
sa.Column("active", sa.Boolean(), server_default=sa.text("0"), nullable=False),
sa.Column("active", sa.Boolean(), server_default=sa.text("false"), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("version", name="uq_platform_settings_version"),

View File

@@ -16,7 +16,7 @@ def upgrade() -> None:
sa.Column("user_id", sa.String(length=64), nullable=False),
sa.Column("token_hash", sa.String(length=128), nullable=False),
sa.Column("auth_version", sa.Integer(), server_default=sa.text("0"), nullable=False),
sa.Column("used", sa.Boolean(), server_default=sa.text("0"), nullable=False),
sa.Column("used", sa.Boolean(), server_default=sa.text("false"), nullable=False),
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),