fp/services/migrations-schema/migrations/00001_create.sql

27 lines
982 B
MySQL
Raw Normal View History

2024-07-30 20:34:25 +00:00
-- api schema, which houses all the tables for api endpoints
-- example: api.discord_interactions becomes accessible at localhost:9000/discord_interactions
CREATE schema api;
2024-08-01 19:16:35 +00:00
-- authenticator is the role which can "impersonate" other users.
CREATE ROLE authenticator LOGIN NOINHERIT NOCREATEDB NOCREATEROLE NOSUPERUSER;
2024-08-01 19:40:19 +00:00
-- web_anon is the role assigned to anonymous web requests
CREATE ROLE web_anon NOLOGIN;
2024-08-01 19:16:35 +00:00
2024-07-30 20:34:25 +00:00
-- schema for @futureporn/capture and @futureporn/bot
CREATE TABLE api.discord_interactions (
2024-08-01 19:16:35 +00:00
id int PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
2024-07-30 20:34:25 +00:00
discord_message_id text NOT NULL,
capture_job_id text NOT NULL
);
2024-08-01 19:16:35 +00:00
-- roles & permissions for our backend automation user
2024-08-01 19:33:36 +00:00
CREATE ROLE automation NOLOGIN;
GRANT automation TO authenticator;
GRANT usage ON SCHEMA api TO automation;
GRANT all ON api.discord_interactions TO automation;
2024-08-01 19:16:35 +00:00
2024-08-01 19:40:19 +00:00
-- role & permissions for web_anon web user
GRANT usage on schema api TO web_anon;
GRANT SELECT ON api.discord_interactions TO web_anon;