cartodb-postgresql/util/create_from_unpackaged.sh
Raul Marin 8ff0ad74af Add regress target
Runs the regress tests without installing the extension
2019-10-28 16:17:29 +01:00

24 lines
795 B
Bash
Executable File

#!/bin/sh
ver=$1
input=cartodb--${ver}.sql
output=cartodb--unpackaged--${ver}.sql
echo "-- Script generated by $0 on `date`" > ${output}
# Migrate CDB functions from public schema to cartodb schema
cat ${input} |
grep '^ *CREATE OR REPLACE FUNCTION' |
grep -v ' cartodb\.' | # should only match DDL hooks
grep -v '.*\quit.*' |
sed 's/).*$/)/' |
sed 's/DEFAULT [^ ,)]*//g' |
sed 's/CREATE OR REPLACE FUNCTION /ALTER FUNCTION public./' |
sed 's/$/ SET SCHEMA cartodb;/' |
sed 's/^/DO LANGUAGE plpgsql \$\$ BEGIN /' |
sed "s/$/ EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Got % (%)', SQLERRM, SQLSTATE; END; \$\$;/" |
cat >> ${output}
# Upgrade all functions
cat ${input} | grep -v 'duplicated extension$' | grep -v '\quit$' | grep -v 'pg_extension_config_dump' >> ${output}