fix: migrations

This commit is contained in:
2019-08-03 00:53:44 +02:00
parent 88d581c529
commit 881a335c90
6 changed files with 29 additions and 20 deletions

View File

@@ -1,3 +1,3 @@
DELETE
FROM migration.functions
WHERE filename = :filename;
WHERE filename = ?;

View File

@@ -4,4 +4,10 @@ VALUES (?, ?, now(), ?, ?, (
from migration.functions f2
where filename = f2.filename
))
ON CONFLICT (filename) DO UPDATE SET
definition = excluded.definition,
up = excluded.up,
down = excluded.down,
version = excluded.version,
executed_at = now()
RETURNING to_json(f);

View File

@@ -1,7 +1,7 @@
INSERT INTO migration.history as h (filename, executed_at, up, down, version)
VALUES (?, now(), ?, ?, (
select coalesce(max(version), 0)+1
from migration.history f2
where filename = f2.filename
from migration.history h2
where h2.filename = filename
))
RETURNING to_json(h);