From 84e624a91b5029dde21699264b384378873bde5e Mon Sep 17 00:00:00 2001 From: "Benjamin A. Shelton" Date: Fri, 30 Oct 2026 14:25:05 -0600 Subject: [PATCH] Moved v0003 migrations into base. --- migrations/base/sqlite/0003_table_updates.sql | 10 ---- .../base/sqlite/base_initial-layout.sql | 56 +++++++++++-------- 2 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 migrations/base/sqlite/0003_table_updates.sql diff --git a/migrations/base/sqlite/0003_table_updates.sql b/migrations/base/sqlite/0003_table_updates.sql deleted file mode 100644 index 1124f39..0000000 --- a/migrations/base/sqlite/0003_table_updates.sql +++ /dev/null @@ -1,10 +0,0 @@ --- @up - -alter table birthdays add column announce boolean default true not null; - --- Anniversaries will be re-added in the future, either as a base table for --- wedding anniversaries + birthdays or as a single purpose table. If the --- former, anniversary types will be implemented as views, and the INSTEAD OF --- trigger will be used for inserts and updates: --- www.sqlite.org/lang_createtrigger.html#instead_of_trigger -drop table anniversaries; \ No newline at end of file diff --git a/migrations/base/sqlite/base_initial-layout.sql b/migrations/base/sqlite/base_initial-layout.sql index c36f06c..e7f29a2 100644 --- a/migrations/base/sqlite/base_initial-layout.sql +++ b/migrations/base/sqlite/base_initial-layout.sql @@ -1,5 +1,28 @@ -- @up --- @version=0002 +-- @version=0003 + +-- Chats. +-- +-- Several tables are dependent upon chats.id so it's created first. + +create table chats ( + id integer primary key, + name text not null +) strict; +insert into chats values (1, 'all chats'); + +create table chat_config ( + chatid integer, + timezone text not null default 'America/Denver', + cron text not null default 'inherit', + scripture_daily text not null default '0 8 * * *', + scripture_daily_enable boolean not null default true, + birthdays_weekly text not null default '30 7 * * 0', + birthdays_weekly_enable boolean not null default true, + birthdays_daily text not null default '30 7 * * 1-6', + birthdays_daily_enable boolean not null default true, + foreign key (chatid) references chats(id) +); -- Members and member metadata. @@ -14,11 +37,18 @@ create index anniversaries_month_day_idx on anniversaries (month, day); create table announcements ( id integer primary key autoincrement, + chatid integer not null, scheduled_for datetime not null, + + -- If enabled, reminders will be generated a week before and a day before the announcement itself. reminders boolean default true not null, title text default '' not null, - content text default '' not null + content text default '' not null, + + foreign key (chatid) references chats(id) ); +create index announcements_chatid_idx on announcements (chatid); +create index announcements_scheduled_for_idx on announcements (scheduled_for); create table birthdays ( id integer primary key autoincrement, @@ -39,6 +69,7 @@ create table birthdays ( -- (March 1st). 0 = no delta (non-leap day) or no preference (no preference -- is handled the same as -1). leap_delta integer not null check (leap_delta >= -1 or leap_delta <= 1), + announce boolean default true not null, foreign key (userid) references users(id), foreign key (chatid) references chats(id) @@ -46,27 +77,6 @@ create table birthdays ( create index birthdays_chatid_idx on birthdays (chatid); create index birthdays_chatid_name_idx on birthdays (chatid, name); --- Chats. - -create table chats ( - id integer primary key, - name text not null -) strict; -insert into chats values (1, 'all chats'); - -create table chat_config ( - chatid integer, - timezone text not null default 'America/Denver', - cron text not null default 'inherit', - scripture_daily text not null default '0 8 * * *', - scripture_daily_enable boolean not null default true, - birthdays_weekly text not null default '30 7 * * 0', - birthdays_weekly_enable boolean not null default true, - birthdays_daily text not null default '30 7 * * 1-6', - birthdays_daily_enable boolean not null default true, - foreign key (chatid) references chats(id) -); - -- System -- Overrides settings.toml.