aboutsummaryrefslogtreecommitdiff
path: root/migrations/2024-08-16-230507_require_guild/up.sql
diff options
context:
space:
mode:
Diffstat (limited to 'migrations/2024-08-16-230507_require_guild/up.sql')
-rw-r--r--migrations/2024-08-16-230507_require_guild/up.sql22
1 files changed, 22 insertions, 0 deletions
diff --git a/migrations/2024-08-16-230507_require_guild/up.sql b/migrations/2024-08-16-230507_require_guild/up.sql
new file mode 100644
index 0000000..06e5cd3
--- /dev/null
+++ b/migrations/2024-08-16-230507_require_guild/up.sql
@@ -0,0 +1,22 @@
+-- This migration will fail with any records in the db. If you are working with a normal server, you
+-- can run:
+--
+-- $ convert_null_guilds --guild $PREVIOUS_SINGLETENANT_GUILD
+--
+-- to set all existing db records to the specified guild. A mixed / fucked up db sceneario will
+-- require you to manually edit the db and ensure `guild` is set in `memes`, `invocation_records`,
+-- and `tombstones`.
+
+DO LANGUAGE plpgsql
+$$
+ BEGIN
+ RAISE NOTICE 'if this migration fails, consider running "convert_null_guilds"';
+ END
+$$;
+
+ALTER TABLE memes
+ ALTER COLUMN guild SET NOT NULL;
+ALTER TABLE invocation_records
+ ALTER COLUMN guild SET NOT NULL;
+ALTER TABLE tombstones
+ ALTER COLUMN guild SET NOT NULL;