aboutsummaryrefslogtreecommitdiff
path: root/src/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'src/migrations')
-rw-r--r--src/migrations/2.sql23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/migrations/2.sql b/src/migrations/2.sql
new file mode 100644
index 0000000..ec0d1b0
--- /dev/null
+++ b/src/migrations/2.sql
@@ -0,0 +1,23 @@
+BEGIN TRANSACTION;
+
+ALTER TABLE payment RENAME TO tmp_payment;
+
+CREATE TABLE IF NOT EXISTS "payment"(
+ "id" INTEGER PRIMARY KEY,
+ "user" 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
+);
+
+INSERT INTO payment(id, user, name, cost, date, frequency, created_at, edited_at, deleted_at)
+SELECT id, user_id, name, cost, date, frequency, created_at, edited_at, deleted_at
+FROM tmp_payment;
+
+DROP TABLE tmp_payment;
+
+COMMIT;