aboutsummaryrefslogtreecommitdiffstats
path: root/migrations
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-04-10 19:33:21 +0100
committerMatthew Lemon <y@yulqen.org>2024-04-10 19:33:21 +0100
commite69391d4f309f6268440632585bbddf3a2a5bd60 (patch)
tree9e0faa4a92f06dbd8c228ba80752ea5f4d89dd17 /migrations
parentd36c48b3251b9da483f06318ecaa14b9a4fa7118 (diff)
First introduction of migrations using golang-migrate
Diffstat (limited to '')
-rw-r--r--migrations/000001_create_datamaps_datamap_line_tables.down.sql2
-rw-r--r--migrations/000001_create_datamaps_datamap_line_tables.up.sql15
-rw-r--r--resources/dbasik.sql (renamed from migrations/dbasik.sql)0
-rw-r--r--resources/setup.sql (renamed from migrations/setup.sql)2
4 files changed, 19 insertions, 0 deletions
diff --git a/migrations/000001_create_datamaps_datamap_line_tables.down.sql b/migrations/000001_create_datamaps_datamap_line_tables.down.sql
new file mode 100644
index 0000000..86f243c
--- /dev/null
+++ b/migrations/000001_create_datamaps_datamap_line_tables.down.sql
@@ -0,0 +1,2 @@
+DROP TABLE IF EXISTS datamaps;
+DROP TABLE IF EXISTS datamap_lines;
diff --git a/migrations/000001_create_datamaps_datamap_line_tables.up.sql b/migrations/000001_create_datamaps_datamap_line_tables.up.sql
new file mode 100644
index 0000000..be96b96
--- /dev/null
+++ b/migrations/000001_create_datamaps_datamap_line_tables.up.sql
@@ -0,0 +1,15 @@
+CREATE TABLE IF NOT EXISTS datamaps (
+ id bigserial PRIMARY KEY,
+ name text,
+ description text,
+ created timestamp(0) with time zone NOT NULL DEFAULT NOW()
+);
+
+CREATE TABLE IF NOT EXISTS datamap_lines (
+ datamap_line_id bigserial PRIMARY KEY,
+ datamap_id bigserial REFERENCES datamaps ON DELETE CASCADE,
+ key text,
+ sheet text,
+ data_type text,
+ cellref text
+);
diff --git a/migrations/dbasik.sql b/resources/dbasik.sql
index b5bb6f9..b5bb6f9 100644
--- a/migrations/dbasik.sql
+++ b/resources/dbasik.sql
diff --git a/migrations/setup.sql b/resources/setup.sql
index 3d95044..dac150f 100644
--- a/migrations/setup.sql
+++ b/resources/setup.sql
@@ -3,4 +3,6 @@ CREATE DATABASE dbasik;
\c dbasik
CREATE ROLE 'dbasik' WITH LOGIN PASSWORD 'dbasik';
+GRANT ALL PRIVILEGES ON DATABASE 'dbasik' TO 'dbasik';
+ALTER DATABASE 'dbasik' OWNER TO 'dbasik';
CREATE EXTENSION IF NOT EXISTS citext;