From ef056edf92b678265a4666e1f9405e3b0ce66a42 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Fri, 16 Aug 2024 21:14:30 -0400 Subject: repo: overhaul for multitenancy --- migrations/2024-08-16-230507_require_guild/up.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 migrations/2024-08-16-230507_require_guild/up.sql (limited to 'migrations/2024-08-16-230507_require_guild/up.sql') 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; -- cgit v1.3.1