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
+18 -18
View File
@@ -66,8 +66,8 @@ fn create_table_writes_yaml_and_history() {
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()),
@@ -96,8 +96,8 @@ fn insert_writes_csv_and_history() {
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()),
@@ -134,7 +134,7 @@ fn drop_table_removes_its_csv() {
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 table Customers with pk id(serial)".to_string()),
)
@@ -172,7 +172,7 @@ fn delete_with_cascade_rewrites_both_csvs() {
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 table Customers with pk id(serial)".to_string()),
)
@@ -181,8 +181,8 @@ fn delete_with_cascade_rewrites_both_csvs() {
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 table Orders with pk id(serial), CustId(int)".to_string()),
@@ -259,8 +259,8 @@ fn create_table_does_not_write_csv_for_empty_table() {
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()),
@@ -288,8 +288,8 @@ fn delete_all_rows_removes_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 table Customers with pk id(serial)".to_string()),
@@ -330,7 +330,7 @@ fn show_table_appends_history_only() {
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 table Customers with pk id(serial)".to_string()),
)
@@ -363,7 +363,7 @@ fn failed_command_does_not_append_history_or_change_yaml() {
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 table Customers with pk id(serial)".to_string()),
)
@@ -375,7 +375,7 @@ fn failed_command_does_not_append_history_or_change_yaml() {
let err = 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 table Customers with pk id(serial)".to_string()),
)
@@ -404,7 +404,7 @@ fn project_yaml_carries_relationship_after_add() {
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()],
None,
)
@@ -413,8 +413,8 @@ fn project_yaml_carries_relationship_after_add() {
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()],
None,