summaryrefslogtreecommitdiff
path: root/haskell/src/SpaceTraders/Database
diff options
context:
space:
mode:
authorJulien Dessaux2023-07-24 00:01:49 +0200
committerJulien Dessaux2023-07-24 00:01:49 +0200
commit565afa5c7b7b2ff7a1fbb7c098aa852a9c2e8dcc (patch)
tree1c25bd37b22dedb0b76cb3dfbcd7a2ec8da332d7 /haskell/src/SpaceTraders/Database
parent[haskell] Prevent que networking code from triggering the API rate limiting (diff)
downloadspacetraders-565afa5c7b7b2ff7a1fbb7c098aa852a9c2e8dcc.tar.gz
spacetraders-565afa5c7b7b2ff7a1fbb7c098aa852a9c2e8dcc.tar.bz2
spacetraders-565afa5c7b7b2ff7a1fbb7c098aa852a9c2e8dcc.zip
[haskell] embed sql migration scripts from external files
Diffstat (limited to 'haskell/src/SpaceTraders/Database')
-rw-r--r--haskell/src/SpaceTraders/Database/000_init.sql25
1 files changed, 25 insertions, 0 deletions
diff --git a/haskell/src/SpaceTraders/Database/000_init.sql b/haskell/src/SpaceTraders/Database/000_init.sql
new file mode 100644
index 0000000..78a62cd
--- /dev/null
+++ b/haskell/src/SpaceTraders/Database/000_init.sql
@@ -0,0 +1,25 @@
+CREATE TABLE schema_version (
+ version INTEGER NOT NULL
+);
+CREATE TABLE tokens (
+ id INTEGER PRIMARY KEY,
+ data TEXT NOT NULL
+);
+CREATE TABLE agents (
+ id INTEGER PRIMARY KEY,
+ data TEXT NOT NULL
+);
+CREATE TABLE contracts (
+ id INTEGER PRIMARY KEY,
+ data TEXT NOT NULL
+);
+CREATE TABLE ships (
+ id INTEGER PRIMARY KEY,
+ data TEXT NOT NULL
+);
+CREATE UNIQUE INDEX ships_data_symbol ON ships (json_extract(data, '$.symbol'));
+CREATE TABLE systems (
+ id INTEGER PRIMARY KEY,
+ data TEXT NOT NULL
+);
+CREATE UNIQUE INDEX systems_data_symbol ON systems (json_extract(data, '$.symbol'));