aboutsummaryrefslogtreecommitdiffstats
path: root/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'migrations')
-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--migrations/dbasik.sql32
-rw-r--r--migrations/setup.sql6
4 files changed, 17 insertions, 38 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/migrations/dbasik.sql
deleted file mode 100644
index b5bb6f9..0000000
--- a/migrations/dbasik.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-CREATE TABLE "datamap" (
- "id" int PRIMARY KEY,
- "name" varchar,
- "description" varchar
-);
-
-CREATE TABLE "datamapline" (
- "id" uuid PRIMARY KEY,
- "datamap_id" uuid,
- "name" string,
- "cellref" string,
- "sheet" string,
- "data_type" string
-);
-
-CREATE TABLE "returnitem" (
- "id" uuid PRIMARY KEY,
- "datamapline_id" uuid,
- "return_id" int,
- "value" string
-);
-
-CREATE TABLE "return" (
- "id" int PRIMARY KEY,
- "name" string
-);
-
-ALTER TABLE "datamapline" ADD FOREIGN KEY ("datamap_id") REFERENCES "datamap" ("id");
-
-ALTER TABLE "returnitem" ADD FOREIGN KEY ("datamapline_id") REFERENCES "datamapline" ("id");
-
-ALTER TABLE "returnitem" ADD FOREIGN KEY ("return_id") REFERENCES "return" ("id");
diff --git a/migrations/setup.sql b/migrations/setup.sql
deleted file mode 100644
index 3d95044..0000000
--- a/migrations/setup.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-/* should be added manually at this point */
-CREATE DATABASE dbasik;
-\c dbasik
-
-CREATE ROLE 'dbasik' WITH LOGIN PASSWORD 'dbasik';
-CREATE EXTENSION IF NOT EXISTS citext;