Mercurial > gemma
annotate schema/updates/0000/01.add_schema_version.sql @ 4434:0ca5e6c4f195
Added tag v4-preview20190918 for changeset b5619087e3e9
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 18 Sep 2019 18:04:39 +0200 |
parents | 7b7c324b318f |
children |
rev | line source |
---|---|
3978
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 CREATE TABLE gemma_schema_version ( |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
2 version int PRIMARY KEY, |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
3 update_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
4 ); |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
5 |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
6 CREATE OR REPLACE FUNCTION get_schema_version() RETURNS int |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
7 LANGUAGE plpgsql |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 AS $$ |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 BEGIN |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 RETURN ( SELECT max(version) FROM gemma_schema_version ); |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 END; |
7b7c324b318f
Added database schema versioning and db update script.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
12 $$; |