From 5b482881797f5f5731195b0046d1272a89a415fe Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 11 Nov 2024 19:33:54 -0800 Subject: [PATCH] refactor to db setup for admin-cli --- db/setup-db.sql | 2 ++ db/{tables.sql => setup-tables.sql} | 0 db/setup-user.sql | 8 ++++++++ db/setup.sql | 12 ++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 db/setup-db.sql rename db/{tables.sql => setup-tables.sql} (100%) create mode 100644 db/setup-user.sql create mode 100644 db/setup.sql diff --git a/db/setup-db.sql b/db/setup-db.sql new file mode 100644 index 0000000..96139fc --- /dev/null +++ b/db/setup-db.sql @@ -0,0 +1,2 @@ +DROP DATABASE IF EXISTS bubble; +CREATE DATABASE bubble; diff --git a/db/tables.sql b/db/setup-tables.sql similarity index 100% rename from db/tables.sql rename to db/setup-tables.sql diff --git a/db/setup-user.sql b/db/setup-user.sql new file mode 100644 index 0000000..01c4649 --- /dev/null +++ b/db/setup-user.sql @@ -0,0 +1,8 @@ +-- Create the user that we'll use for service data +DO $SERVICE_USER_CREATION$ +BEGIN + CREATE ROLE bubble_api; + EXCEPTION WHEN duplicate_object THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; +END +$SERVICE_USER_CREATION$; + diff --git a/db/setup.sql b/db/setup.sql new file mode 100644 index 0000000..338c52a --- /dev/null +++ b/db/setup.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS users ( + id INTEGER, + name VARCHAR(256), + PRIMARY KEY (id) +); + + +CREATE TABLE IF NOT EXISTS invites ( + id BIGINT, + expires INTEGER, + PRIMARY KEY (id) +);