From c22ab7b5b47406c946205e40e5e92193b69f951e Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 20 Feb 2025 16:07:06 -0800 Subject: [PATCH] Add check constraints to ensure names aren't empty --- core/sql/0001_initial_schema.sql | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/sql/0001_initial_schema.sql b/core/sql/0001_initial_schema.sql index 1641210..a80e9a3 100644 --- a/core/sql/0001_initial_schema.sql +++ b/core/sql/0001_initial_schema.sql @@ -2,21 +2,24 @@ create table sources( name text not null, state blob, lastUpdated int not null, - primary key (name) + primary key (name), + check (name <> '') ) strict; create table actions( source text not null, name text not null, argv blob not null, unique (source, name) on conflict replace, - foreign key (source) references sources (name) on delete cascade + foreign key (source) references sources (name) on delete cascade, + check (name <> '') ) strict; create table envs( source text not null, name text not null, value text not null, unique (source, name) on conflict replace, - foreign key (source) references sources (name) on delete cascade + foreign key (source) references sources (name) on delete cascade, + check (name <> '') ) strict; create table items( source text not null, @@ -33,13 +36,15 @@ create table items( tts int, action blob, primary key (source, id), - foreign key (source) references sources (name) on delete cascade + foreign key (source) references sources (name) on delete cascade, + check (id <> '') ) strict; create table channels( name text not null, source text not null, unique (name, source) on conflict replace - foreign key (source) references sources (name) on delete cascade + foreign key (source) references sources (name) on delete cascade, + check (name <> '') ) strict; create table password( id int not null,