From d3fbecc57b5d6fa3223b945a45fe21eb78ffd49b Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 18 Oct 2024 23:25:21 -0400 Subject: Switch to blanking tombstoned data with null, not empty string. This accomplishes two things: * It removes the need for an additional `channel_name_reservation` table, since `channel.name` now only contains non-null values for active channels, and * It nicely dovetails with the idea that `null` means an unknown value in SQL-land. --- migrations/20241017005219_retain_deleted.sql | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'migrations/20241017005219_retain_deleted.sql') diff --git a/migrations/20241017005219_retain_deleted.sql b/migrations/20241017005219_retain_deleted.sql index 6205482..aed87f4 100644 --- a/migrations/20241017005219_retain_deleted.sql +++ b/migrations/20241017005219_retain_deleted.sql @@ -9,33 +9,18 @@ create table channel ( not null primary key, name text - not null, + null + unique, created_sequence bigint unique not null, created_at text - not null, - unique (id, name) + not null ); insert into channel (id, name, created_sequence, created_at) select id, name, created_sequence, created_at from old_channel; -create table channel_name_reservation ( - id text - not null - unique, - name text - not null - unique, - primary key (id, name), - foreign key (id, name) - references channel (id, name) -); - -insert into channel_name_reservation (id, name) -select id, name from old_channel; - create table channel_deleted ( id text not null @@ -64,7 +49,7 @@ create table message ( sent_at text not null, body text - not null + null ); insert into message (id, channel, sender, sent_sequence, sent_at, body) -- cgit v1.2.3