Revision 6916
Added by Aaron Marcuse-Kubitza about 12 years ago
Makefile | ||
---|---|---|
19 | 19 |
clean: _always |
20 | 20 |
$(RM) $(all) |
21 | 21 |
|
22 |
%/reinstall: _always %/uninstall %/install ; |
|
23 |
|
|
24 |
##### Installation |
|
25 |
|
|
26 |
schemas := temp functions py_functions public |
|
27 |
install: $(schemas:%=%/install) ; |
|
28 |
|
|
29 |
schemasReversed := public py_functions functions temp |
|
30 |
uninstall: $(schemasReversed:%=%/uninstall) ; |
|
31 |
|
|
32 |
psqlOpts := --set ON_ERROR_STOP=1 --quiet |
|
33 |
asAdmin := sudo -E -u postgres |
|
34 |
psqlAsAdmin := $(asAdmin) psql $(psqlOpts) |
|
35 |
# -E preserves env vars so PGOPTIONS is passed to psql |
|
36 |
psqlAsAdminVegbien := $(psqlAsAdmin) vegbien |
|
37 |
psqlNoSearchPath := env no_search_path=1 ../bin/psql_script_vegbien |
|
38 |
|
|
39 |
#### public |
|
40 |
|
|
41 |
confirmRmPublicSchema = $(call confirm,WARNING: This will delete the current\ |
|
42 |
public schema of your VegBIEN DB!,To save it: make schemas/rotate) |
|
43 |
|
|
44 |
rmPublicSchema := $(call rmSchemaCmd,public) |
|
45 |
|
|
46 |
public/install: vegbien.sql _always |
|
47 |
-echo $(call mkSchemaCmd,public)|$(psqlNoSearchPath) |
|
48 |
<$< $(psqlNoSearchPath) |
|
49 |
# ignore errors if schema exists |
|
50 |
# public schema will be owned by bien |
|
51 |
# don't include public in the search_path |
|
52 |
|
|
53 |
public/uninstall: _always |
|
54 |
@$(confirmRmPublicSchema) |
|
55 |
echo $(rmPublicSchema)|$(psqlNoSearchPath) |
|
56 |
|
|
57 |
rename/%: _always |
|
58 |
echo 'ALTER SCHEMA public RENAME TO "$*";'|$(psqlNoSearchPath) |
|
59 |
$(MAKE) public/install |
|
60 |
|
|
61 |
rotate: _always rename/public.$(version) ; |
|
62 |
|
|
63 |
#### py_functions |
|
64 |
|
|
65 |
py_functions/install: py_functions.sql _always |
|
66 |
-<$< env public= $(psqlAsAdminVegbien) |
|
67 |
# ignore errors if schema exists |
|
68 |
|
|
69 |
#### Others |
|
70 |
|
|
71 |
%/install: %.sql _always |
|
72 |
-<$< $(psqlNoSearchPath) |
|
73 |
# ignore errors if schema exists |
|
74 |
|
|
75 |
%/uninstall: _always |
|
76 |
echo $(call rmSchemaCmd,$*)|$(psqlNoSearchPath) |
|
77 |
|
|
78 |
# Needed on Ubuntu 12.04 (also other Linuxes?) because %/reinstall is ignored. |
|
79 |
temp/reinstall: _always temp/uninstall temp/install ; |
|
80 |
|
|
22 | 81 |
##### MySQL schema for ERD |
23 | 82 |
|
24 | 83 |
repl = ../bin/repl |
... | ... | |
26 | 85 |
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv filter_ERD.csv |
27 | 86 |
$(repl) <$(wordlist 1,2,$+)|$(repl) $(word 3,$+) >$@ |
28 | 87 |
|
29 |
##### DDLs
|
|
88 |
##### DDL generation
|
|
30 | 89 |
|
31 | 90 |
pg_dump = env schema= ../bin/pg_dump_vegbien $(1) >$@ |
32 | 91 |
|
Also available in: Unified diff
Moved schemas-related commands from root Makefile to schemas/Makefile