From 0b191f5c48edffc9da3e38c284e9640fd82e7cb1 Mon Sep 17 00:00:00 2001
From: Joris
Date: Mon, 5 Jun 2017 18:02:13 +0200
Subject: Replace persistent by sqlite-simple

---
 src/migrations/1.sql | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 src/migrations/1.sql

(limited to 'src/migrations/1.sql')

diff --git a/src/migrations/1.sql b/src/migrations/1.sql
new file mode 100644
index 0000000..d7c300e
--- /dev/null
+++ b/src/migrations/1.sql
@@ -0,0 +1,65 @@
+CREATE TABLE IF NOT EXISTS "user" (
+  "id" INTEGER PRIMARY KEY,
+  "creation" TIMESTAMP NOT NULL,
+  "email" VARCHAR NOT NULL,
+  "name" VARCHAR NOT NULL,
+  CONSTRAINT "uniq_user_email" UNIQUE ("email"),
+  CONSTRAINT "uniq_user_name" UNIQUE ("name")
+);
+
+CREATE TABLE IF NOT EXISTS "job" (
+  "id" INTEGER PRIMARY KEY,
+  "kind" VARCHAR NOT NULL,
+  "last_execution" TIMESTAMP NULL,
+  "last_check" TIMESTAMP NULL,
+  CONSTRAINT "uniq_job_kind" UNIQUE ("kind")
+);
+
+CREATE TABLE IF NOT EXISTS "sign_in"(
+  "id" INTEGER PRIMARY KEY,
+  "token" VARCHAR NOT NULL,
+  "creation" TIMESTAMP NOT NULL,
+  "email" VARCHAR NOT NULL,
+  "is_used" BOOLEAN NOT NULL,
+  CONSTRAINT "uniq_sign_in_token" UNIQUE ("token")
+);
+
+CREATE TABLE IF NOT EXISTS "payment"(
+  "id" INTEGER PRIMARY KEY,
+  "user_id" INTEGER NOT NULL REFERENCES "user",
+  "name" VARCHAR NOT NULL,
+  "cost" INTEGER NOT NULL,
+  "date" DATE NOT NULL,
+  "frequency" VARCHAR NOT NULL,
+  "created_at" TIMESTAMP NOT NULL,
+  "edited_at" TIMESTAMP NULL,
+  "deleted_at" TIMESTAMP NULL
+);
+
+CREATE TABLE IF NOT EXISTS "income"(
+  "id" INTEGER PRIMARY KEY,
+  "user_id" INTEGER NOT NULL REFERENCES "user",
+  "date" DATE NOT NULL,
+  "amount" INTEGERNOT NULL,
+  "created_at" TIMESTAMP NOT NULL,
+  "edited_at" TIMESTAMP NULL,
+  "deleted_at" TIMESTAMP NULL
+);
+
+CREATE TABLE IF NOT EXISTS "category"(
+  "id" INTEGER PRIMARY KEY,
+  "name" VARCHAR NOT NULL,
+  "color" VARCHAR NOT NULL,
+  "created_at" TIMESTAMP NOT NULL,
+  "edited_at" TIMESTAMP NULL,
+  "deleted_at" TIMESTAMP NULL
+);
+
+CREATE TABLE IF NOT EXISTS "payment_category"(
+  "id" INTEGER PRIMARY KEY,
+  "name" VARCHAR NOT NULL,
+  "category" INTEGER NOT NULL REFERENCES "category",
+  "created_at" TIMESTAMP NOT NULL,
+  "edited_at" TIMESTAMP NULL,
+  CONSTRAINT "uniq_payment_category_name" UNIQUE ("name")
+);
-- 
cgit v1.2.3

