forked from enova/pgl_ddl_deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgl_ddl_deploy-sql-maker.sh
More file actions
executable file
·47 lines (36 loc) · 1.1 KB
/
Copy pathpgl_ddl_deploy-sql-maker.sh
File metadata and controls
executable file
·47 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -eu
last_version=2.3
new_version=2.4
last_version_file=pgl_ddl_deploy--${last_version}.sql
new_version_file=pgl_ddl_deploy--${new_version}.sql
update_file=pgl_ddl_deploy--${last_version}--${new_version}.sql
rm -f $update_file
rm -f $new_version_file
create_update_file_with_header() {
cat << EOM > $update_file
/* $update_file */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION pgl_ddl_deploy" to load this file. \quit
EOM
}
add_sql_to_file() {
sql=$1
file=$2
echo "$sql" >> $file
}
add_file() {
s=$1
d=$2
(cat "${s}"; echo; echo) >> "$d"
}
create_update_file_with_header
# Add view and function changes
add_file schema/2.4.sql $update_file
add_file functions/common_exclude_alter_table_subcommands.sql $update_file
add_file functions/rewrite_transaction_safe.sql $update_file
add_file functions/set_tag_defaults.sql $update_file
add_file views/event_trigger_schema.sql $update_file
# Only copy diff and new files after last version, and add the update script
cp $last_version_file $new_version_file
cat $update_file >> $new_version_file