This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AUT | |
BEL | |
BGR | |
CYP | |
CZE | |
DEU | |
DNK | |
ESP | |
EST | |
FIN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION add_timestamps_to_table(_table text, _type text) RETURNS void AS $$ | |
BEGIN | |
EXECUTE format('ALTER TABLE %I ADD COLUMN IF NOT EXISTS created_at %s', _table, _type); | |
EXECUTE format('ALTER TABLE %I ADD COLUMN IF NOT EXISTS updated_at %s', _table, _type); | |
END; | |
$$ LANGUAGE 'plpgsql'; | |
CREATE OR REPLACE FUNCTION set_timestamps_not_null_on_table(_table text) RETURNS void AS $$ | |
BEGIN | |
EXECUTE format('ALTER TABLE %I ALTER COLUMN created_at SET NOT NULL', _table); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$ | |
DECLARE r pg_catalog.pg_class%rowtype; | |
DECLARE _max_id int; | |
DECLARE _table_name text; | |
DECLARE _column_name text; | |
DECLARE _result int; | |
BEGIN | |
FOR r IN | |
select * from pg_catalog.pg_class where relkind = 'S' | |
LOOP |