Project

General

Profile

« Previous | Next » 

Revision 2091

main Makefile: VegBIEN DB: Added functions schema targets

View differences:

Makefile
33 33
# File editing
34 34
sudoAppend = echo $$'$(2)'|sudo tee -a $(1) >/dev/null
35 35

  
36
# DB
37
mkSchemaCmd = 'CREATE SCHEMA $(1);'
38
rmSchemaCmd = 'DROP SCHEMA IF EXISTS $(1) CASCADE;'
39

  
36 40
##### Environment
37 41

  
38 42
export PGOPTIONS = --client-min-messages=WARNING
......
164 168
confirmRmPublicSchema = $(call confirm,WARNING: This will delete the current\
165 169
public schema of your VegBIEN DB!,To save it: make schemas/rotate)
166 170

  
167
rmPublicSchema := 'DROP SCHEMA IF EXISTS public CASCADE;'
171
rmPublicSchema := $(call rmSchemaCmd,public)
168 172

  
169
db: mk_db schemas/install _always ;
173
db: mk_db rm_initial_public schemas/functions/clear schemas/install _always ;
170 174

  
171 175
mk_db: _always
172 176
	-echo "CREATE USER bien PASSWORD '$(bienPassword)';"|$(psqlAsAdmin)
173 177
	-echo "CREATE DATABASE vegbien WITH OWNER bien TEMPLATE template1 \
174 178
ENCODING 'UTF8' LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';"|$(psqlAsAdmin)
179
# ignore errors if user or database exists
180

  
181
rm_initial_public: _always
175 182
	@$(confirmRmPublicSchema)
176 183
	echo $(rmPublicSchema)|$(psqlAsAdmin) vegbien
177
# ignore errors if user or database exists
178 184
# drop public schema *as admin* because it starts out owned by postgres
179 185

  
180 186
rm_db: _always
......
187 193
#### public schema
188 194

  
189 195
schemas/install: schemas/vegbien.sql _always
190
	-echo "CREATE SCHEMA public;"|$(psqlAsBien)
196
	-echo $(call mkSchemaCmd,public)|$(psqlAsBien)
191 197
	<$< $(psqlAsBien)
192 198
# ignore errors if schema exists
193 199
# public schema will be owned by bien
......
204 210
	@$(confirmRmPublicSchema)
205 211
	$(psqlAsBien) <schemas/vegbien_empty.sql
206 212

  
213
#### functions schema
214

  
215
confirmRmFunctions = $(call confirm,WARNING:\
216
This will delete the functions schema of your VegBIEN DB!)
217

  
218
schemas/functions/clear: _always
219
	@$(confirmRmFunctions)
220
	echo $(call rmSchemaCmd,functions)|$(psqlAsBien)
221
	echo $(call mkSchemaCmd,functions)|$(psqlAsBien)
222

  
207 223
##### MySQL
208 224

  
209 225
mysql: _always $(call forOs,mysql) mysql_user

Also available in: Unified diff