You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cartodb-postgresql/util/create_from_unpackaged.sh

24 lines
795 B

#!/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}