refactor: ColumnSpec / AddColumn carry constraint fields (ADR-0029 scaffolding)

Expand ColumnSpec and Command::AddColumn with the four
ADR-0029 constraint slots (not_null, unique, default, check),
all defaulting off; `Database::add_column` now takes a
ColumnSpec. No behaviour change — the grammar to set the
fields and the DDL to enforce them land in the following
commits. Isolated here so those commits stay readable.

Adds ColumnSpec::new for the unconstrained case; 110 call
sites updated. 1172 tests pass; clippy clean.
This commit is contained in:
claude@clouddev1
2026-05-19 14:04:36 +00:00
parent 7bfd213ab3
commit eff2ee8d14
15 changed files with 237 additions and 194 deletions
+13 -14
View File
@@ -44,8 +44,8 @@ fn rebuild_restores_schema_only_project() {
db.create_table(
"Customers".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Serial },
ColumnSpec { name: "Name".to_string(), ty: Type::Text },
ColumnSpec::new("id".to_string(), Type::Serial),
ColumnSpec::new("Name".to_string(), Type::Text),
],
vec!["id".to_string()],
Some("create table Customers with pk id(serial)".to_string()),
@@ -98,8 +98,8 @@ fn rebuild_restores_rows_from_csv() {
db.create_table(
"Customers".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Serial },
ColumnSpec { name: "Name".to_string(), ty: Type::Text },
ColumnSpec::new("id".to_string(), Type::Serial),
ColumnSpec::new("Name".to_string(), Type::Text),
],
vec!["id".to_string()],
Some("create".to_string()),
@@ -165,7 +165,7 @@ fn rebuild_restores_relationships_and_cascade_behaviour() {
rt().block_on(async {
db.create_table(
"Customers".to_string(),
vec![ColumnSpec { name: "id".to_string(), ty: Type::Serial }],
vec![ColumnSpec::new("id".to_string(), Type::Serial)],
vec!["id".to_string()],
Some("create".to_string()),
)
@@ -174,8 +174,8 @@ fn rebuild_restores_relationships_and_cascade_behaviour() {
db.create_table(
"Orders".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Serial },
ColumnSpec { name: "CustId".to_string(), ty: Type::Int },
ColumnSpec::new("id".to_string(), Type::Serial),
ColumnSpec::new("CustId".to_string(), Type::Int),
],
vec!["id".to_string()],
Some("create".to_string()),
@@ -265,8 +265,8 @@ fn rebuild_reports_fatal_error_on_bad_csv_row() {
db.create_table(
"Numbers".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Serial },
ColumnSpec { name: "n".to_string(), ty: Type::Int },
ColumnSpec::new("id".to_string(), Type::Serial),
ColumnSpec::new("n".to_string(), Type::Int),
],
vec!["id".to_string()],
Some("create".to_string()),
@@ -326,7 +326,7 @@ fn rebuild_preserves_created_at_from_yaml() {
rt().block_on(async {
db.create_table(
"T".to_string(),
vec![ColumnSpec { name: "id".to_string(), ty: Type::Serial }],
vec![ColumnSpec::new("id".to_string(), Type::Serial)],
vec!["id".to_string()],
Some("create".to_string()),
)
@@ -377,8 +377,7 @@ fn rebuild_preserves_created_at_from_yaml() {
// describe is read-only; force a rewrite by adding a column.
db.add_column(
"T".to_string(),
"Note".to_string(),
Type::Text,
ColumnSpec::new("Note", Type::Text),
Some("add column".to_string()),
)
.await
@@ -410,8 +409,8 @@ fn rebuild_restores_indexes() {
db.create_table(
"Customers".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Serial },
ColumnSpec { name: "Email".to_string(), ty: Type::Text },
ColumnSpec::new("id".to_string(), Type::Serial),
ColumnSpec::new("Email".to_string(), Type::Text),
],
vec!["id".to_string()],
Some("create table Customers with pk id(serial)".to_string()),