-- 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;
