Revision 6916
Added by Aaron Marcuse-Kubitza about 12 years ago
schemas/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 |
|
Makefile | ||
---|---|---|
214 | 214 |
psqlAsAdmin := $(asAdmin) psql $(psqlOpts) |
215 | 215 |
# -E preserves env vars so PGOPTIONS is passed to psql |
216 | 216 |
psqlAsAdminVegbien := $(psqlAsAdmin) vegbien |
217 |
psqlNoSearchPath := env no_search_path=1 bin/psql_script_vegbien |
|
218 | 217 |
bienPassword := $(shell cat config/bien_password) |
219 | 218 |
bienReadPassword := $(shell cat config/bien_read_password) |
220 | 219 |
|
... | ... | |
257 | 256 |
|
258 | 257 |
reinstall_db: _always rm_db db ; |
259 | 258 |
|
260 |
#### Schemas |
|
261 |
|
|
262 |
schemas := temp functions py_functions public |
|
263 |
schemas/install: $(schemas:%=schemas/%/install) ; |
|
264 |
|
|
265 |
schemasReversed := public py_functions functions temp |
|
266 |
schemas/uninstall: $(schemasReversed:%=schemas/%/uninstall) ; |
|
267 |
|
|
268 |
### public |
|
269 |
|
|
270 |
schemas/public/install: schemas/vegbien.sql _always |
|
271 |
-echo $(call mkSchemaCmd,public)|$(psqlNoSearchPath) |
|
272 |
<$< $(psqlNoSearchPath) |
|
273 |
# ignore errors if schema exists |
|
274 |
# public schema will be owned by bien |
|
275 |
# don't include public in the search_path |
|
276 |
|
|
277 |
schemas/public/uninstall: _always |
|
278 |
@$(confirmRmPublicSchema) |
|
279 |
echo $(rmPublicSchema)|$(psqlNoSearchPath) |
|
280 |
|
|
281 |
schemas/rename/%: _always |
|
282 |
echo 'ALTER SCHEMA public RENAME TO "$*";'|$(psqlNoSearchPath) |
|
283 |
$(MAKE) schemas/public/install |
|
284 |
|
|
285 |
schemas/rotate: _always schemas/rename/public.$(version) ; |
|
286 |
|
|
287 |
### py_functions |
|
288 |
|
|
289 |
schemas/py_functions/install: schemas/py_functions.sql _always |
|
290 |
-<$< env public= $(psqlAsAdminVegbien) |
|
291 |
# ignore errors if schema exists |
|
292 |
|
|
293 |
### Others |
|
294 |
|
|
295 |
schemas/%/install: schemas/%.sql _always |
|
296 |
-<$< $(psqlNoSearchPath) |
|
297 |
# ignore errors if schema exists |
|
298 |
|
|
299 |
schemas/%/uninstall: _always |
|
300 |
echo $(call rmSchemaCmd,$*)|$(psqlNoSearchPath) |
|
301 |
|
|
302 |
# Needed on Ubuntu 12.04 (also other Linuxes?) because %/reinstall is ignored. |
|
303 |
schemas/temp/reinstall: _always schemas/temp/uninstall schemas/temp/install ; |
|
304 |
|
|
305 | 259 |
##### MySQL |
306 | 260 |
|
307 | 261 |
mysql: _always $(call forOs,mysql) mysql_user |
Also available in: Unified diff
Moved schemas-related commands from root Makefile to schemas/Makefile