Project

General

Profile

1
#!/bin/bash -e
2
auto_fwd=1
3
. "$(dirname "${BASH_SOURCE[0]}")"/in_datasrc_dir.run
4
.rel import.run
5

    
6
if self_not_included; then
7

    
8
subdirs=($(cat "$top_dir"/import_order.txt))
9

    
10
# to reinstall staging tables: rm=1 .../run import
11

    
12
schema/rm()
13
{
14
	begin_target
15
	psql <<EOF
16
DROP SCHEMA IF EXISTS "$schema" CASCADE;
17
EOF
18
}
19

    
20
schema/make()
21
{
22
	begin_target
23
	if remaking; then schema/rm; fi
24
	pattern='schema .* already exists' ignore_e=3 ignore_err_msg psql <<EOF
25
CREATE SCHEMA "$schema";
26
EOF
27
}
28

    
29
import()
30
{
31
	begin_target
32
	if remaking; then schema/rm; fi
33
	if ! benign_error=1 pg_schema_exists; then # uses $schema
34
		schema/make
35
		datasrc_make sql/install </dev/null
36
			# </dev/null because for datasources w/o SQL files, cat will try to
37
			# read from stdin
38
	fi
39
	fwd_self
40
}
41

    
42
fi
(2-2/17)