This file contains 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 set_seq_vals(schema_name TEXT) | |
RETURNS TEXT[] | |
AS $$ | |
schemaname = schema_name if schema_name else 'public' | |
plpy.execute("SET SEARCH_PATH=%s,public" % schemaname) | |
tables = plpy.execute("SELECT tablename FROM pg_tables WHERE schemaname = '%s'" % schemaname); | |
altered_seqs = [] | |
for t in tables: | |
cols = plpy.execute("SELECT column_name, column_default, data_type, is_nullable FROM information_schema.columns WHERE table_name = '%s' AND data_type in ('integer', 'bigint') AND column_default IS NOT NULL" % t["tablename"]) | |
for c in cols: |