Skip to content

bug: empty-string column @default: "" — codegen keeps it, migrate/verify drops it (sqlite/d1) #235

Description

@dmealing

Problem

An empty-string column default (@default: "") is handled inconsistently between codegen and the migrate/verify path on sqlite/d1:

  • Codegen (Drizzle) emits .default("") — keeps it.
  • buildExpectedSchema / the diff appears to DROP the empty-string default (treats "" as absent), so meta verify --dialect d1 reports the column as drift against a DB that has DEFAULT '', and meta migrate won't reconcile it.

Non-empty defaults (0, 'abstains', '[]') round-trip fine; only the empty string is dropped — a classic falsy-"" bug.

Repro

Model a field.string @default: "" on an entity, generate + apply to sqlite/d1 (column gets DEFAULT ''), then meta verify --dialect d1 → the column reports change-column-default drift even though metadata and DB agree.

Impact

A consumer either can't declare an empty-string default (it perpetually drifts) or gets a codegen-vs-migrate disagreement (Drizzle says .default(""), the DB rebuild drops it). Surfaced while reconciling a reference-impl's D1 schema; worked around there by not declaring the (vestigial) empty-string defaults. Likely a if (default) / falsy check in the expected-schema default handling that should be default !== undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions