From b422be184e01b4cc35b9c9a6921379080c24edb3 Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Fri, 4 Oct 2024 22:12:15 -0400
Subject: Start fresh with database migrations.

The migration path from the original project inception to now was complicated and buggy, and stranded _both_ Kit and I with broken databases due to oversights and incomplete migrations. We've agreed to start fresh, once.

If this is mistakenly started with an original-schema-flavour DB, startup will be aborted.
---
 migrations/20240928002608_channel_lifecycle.sql | 57 -------------------------
 1 file changed, 57 deletions(-)
 delete mode 100644 migrations/20240928002608_channel_lifecycle.sql

(limited to 'migrations/20240928002608_channel_lifecycle.sql')

diff --git a/migrations/20240928002608_channel_lifecycle.sql b/migrations/20240928002608_channel_lifecycle.sql
deleted file mode 100644
index bc690d7..0000000
--- a/migrations/20240928002608_channel_lifecycle.sql
+++ /dev/null
@@ -1,57 +0,0 @@
-alter table channel
-rename to old_channel;
-
--- Add new columns
-create table channel (
-	id text
-		not null
-		primary key,
-	name text
-		not null
-		unique,
-	created_at text
-		not null
-);
-
--- Transfer data from original table
-insert into channel
-select
-	channel.id,
-	channel.name,
-	coalesce(
-		min(message.sent_at),
-		strftime('%FT%R:%f+00:00', 'now', 'utc')
-	) as created_at
-from old_channel as channel
-	left join message on channel.id = message.channel
-group by channel.id, channel.name;
-
--- Fix up `message` foreign keys
-alter table message
-rename to old_message;
-
-create table message (
-	id text
-		not null
-		primary key,
-	sequence bigint
-		not null,
-	channel text
-		not null
-		references channel (id),
-	sender text
-		not null
-		references login (id),
-	body text
-		not null,
-	sent_at text
-		not null,
-	unique (channel, sequence)
-);
-
-insert into message
-select * from old_message;
-
--- Bury the bodies respectfully
-drop table old_message;
-drop table old_channel;
-- 
cgit v1.2.3

