diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-18 23:42:08 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-18 23:42:08 -0400 |
| commit | 82338ddcb7f14ffbd584a954689f02b6e6a7988e (patch) | |
| tree | 1e0a525766ca45067bb122cad3af69437db504ca /migrations | |
| parent | bde5aea211e9838b4511a2b57c6a256fe89b66ab (diff) | |
| parent | 17b62b3458e3a992b93cd485b05d3fb112dd349a (diff) | |
Merge branch 'wip/retain-deleted'
Diffstat (limited to 'migrations')
| -rw-r--r-- | migrations/20241017005219_retain_deleted.sql | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/migrations/20241017005219_retain_deleted.sql b/migrations/20241017005219_retain_deleted.sql new file mode 100644 index 0000000..aed87f4 --- /dev/null +++ b/migrations/20241017005219_retain_deleted.sql @@ -0,0 +1,77 @@ +alter table channel +rename to old_channel; + +alter table message +rename to old_message; + +create table channel ( + id text + not null + primary key, + name text + null + unique, + created_sequence bigint + unique + not null, + created_at text + not null +); + +insert into channel (id, name, created_sequence, created_at) +select id, name, created_sequence, created_at from old_channel; + +create table channel_deleted ( + id text + not null + primary key + references channel (id), + deleted_sequence bigint + unique + not null, + deleted_at text + not null +); + +create table message ( + id text + not null + primary key, + channel text + not null + references channel (id), + sender text + not null + references login (id), + sent_sequence bigint + unique + not null, + sent_at text + not null, + body text + null +); + +insert into message (id, channel, sender, sent_sequence, sent_at, body) +select id, channel, sender, sent_sequence, sent_at, body from old_message; + +create table message_deleted ( + id text + not null + primary key + references message (id), + deleted_sequence bigint + unique + not null, + deleted_at text + not null +); + +drop table old_message; +drop table old_channel; + +create index message_sent_at +on message (sent_at); + +create index channel_created_at +on channel (created_at); |
