feature: Add SQL for migration
This commit is contained in:
13
src/main/resources/sql/migration/createFunctionShema.sql
Normal file
13
src/main/resources/sql/migration/createFunctionShema.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
CREATE SCHEMA IF NOT EXISTS migration;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS migration.functions
|
||||
(
|
||||
filename text PRIMARY KEY,
|
||||
definition text NOT NULL,
|
||||
executed_at timestamp DEFAULT now() NOT NULL,
|
||||
up text NOT NULL,
|
||||
down text NOT NULL,
|
||||
version int NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS migration.version_seq;
|
||||
12
src/main/resources/sql/migration/createHistoryShema.sql
Normal file
12
src/main/resources/sql/migration/createHistoryShema.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE SCHEMA IF NOT EXISTS migration;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS migration.history
|
||||
(
|
||||
filename text PRIMARY KEY,
|
||||
executed_at timestamp DEFAULT now() NOT NULL,
|
||||
up text NOT NULL,
|
||||
down text NOT NULL,
|
||||
version int NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS migration.version_seq;
|
||||
3
src/main/resources/sql/migration/deleteFunction.sql
Normal file
3
src/main/resources/sql/migration/deleteFunction.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DELETE
|
||||
FROM migration.functions
|
||||
WHERE filename = :filename;
|
||||
3
src/main/resources/sql/migration/deleteHistory.sql
Normal file
3
src/main/resources/sql/migration/deleteHistory.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DELETE
|
||||
FROM migration.history
|
||||
WHERE filename = :filename;
|
||||
2
src/main/resources/sql/migration/findAllFunction.sql
Normal file
2
src/main/resources/sql/migration/findAllFunction.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
SELECT json_object_agg(filename, f)
|
||||
FROM migration.functions f;
|
||||
2
src/main/resources/sql/migration/findAllHistory.sql
Normal file
2
src/main/resources/sql/migration/findAllHistory.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
SELECT json_object_agg(filename, f)
|
||||
FROM migration.functions f;
|
||||
1
src/main/resources/sql/migration/getNextVersion.sql
Normal file
1
src/main/resources/sql/migration/getNextVersion.sql
Normal file
@@ -0,0 +1 @@
|
||||
SELECT nextval('migration.version_seq');
|
||||
2
src/main/resources/sql/migration/insertFunction.sql
Normal file
2
src/main/resources/sql/migration/insertFunction.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
INSERT INTO migration.functions (filename, definition, up, down, version)
|
||||
VALUES (:filename, :definition, :up, :down, :version);
|
||||
2
src/main/resources/sql/migration/insertHistory.sql
Normal file
2
src/main/resources/sql/migration/insertHistory.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
INSERT INTO migration.history (filename, up, down, version)
|
||||
VALUES (:filename, :up, :down, :version);
|
||||
Reference in New Issue
Block a user