db: column-constraint infrastructure — NOT NULL / UNIQUE / DEFAULT (ADR-0029)

The database layer now honours the ColumnSpec constraint
fields end to end, ahead of the grammar that lets users type
them.

- `do_create_table` emits ` NOT NULL` / ` UNIQUE` / ` DEFAULT
  <literal>` per column via the new `column_constraints_sql`
  helper (the default literal bound against the column's type).
- `ReadColumn` gains `default_sql`, read from
  `pragma_table_info.dflt_value`; `schema_to_ddl` emits it, so
  the rebuild-table primitive preserves DEFAULT — it already
  preserved NOT NULL / UNIQUE.
- `ColumnDescription` gains `unique` / `default`;
  `do_describe_table` now sources columns from `read_schema`
  (one source of per-column truth) and `constraints_display`
  lists PK / NOT NULL / UNIQUE / DEFAULT.

No user-facing change yet — no grammar produces constrained
columns. Tests exercise creation, enforcement, describe, and
rebuild-preservation programmatically.

1177 tests pass (+5); clippy clean.
This commit is contained in:
claude@clouddev1
2026-05-19 14:18:45 +00:00
parent eff2ee8d14
commit a60e879f20
5 changed files with 281 additions and 45 deletions
+4
View File
@@ -1115,6 +1115,8 @@ mod tests {
sqlite_type: "INTEGER".to_string(),
notnull: false,
primary_key: true,
unique: false,
default: None,
},
ColumnDescription {
name: "Name".to_string(),
@@ -1122,6 +1124,8 @@ mod tests {
sqlite_type: "TEXT".to_string(),
notnull: false,
primary_key: false,
unique: false,
default: None,
},
],
outbound_relationships: Vec::new(),