Project

General

Profile

« Previous | Next » 

Revision 1097

input.Makefile: Don't try to recreate an input DB if it already exists

View differences:

inputs/input.Makefile
245 245
mysqlAsRoot := $(call mysqlAs,root)
246 246
dbAsBien := $(call mysqlAs,bien)
247 247

  
248
dbExists = $(shell echo "SHOW DATABASES LIKE '$(db)';"|$(mysqlAsRoot))
249

  
250
define createDb
251
echo "CREATE DATABASE IF NOT EXISTS $(db) DEFAULT CHARACTER SET latin1;"\
252
|$(mysqlAsRoot)
253
-$(mysqlAsRoot) --database=$(db) <$<
254
endef
255
# ignore errors in db import so that GRANT will still be run
256

  
248 257
db: $(dbFile) _always
249
	echo "CREATE DATABASE $(db) DEFAULT CHARACTER SET latin1;"|$(mysqlAsRoot)
250
	-$(mysqlAsRoot) --database=$(db) <$<
258
	$(if $(dbExists),,$(createDb))
251 259
	echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysqlAsRoot)
252
# ignore errors in db import so that GRANT will still be run
253 260

  
254 261
rm_db: _always
255 262
	-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysqlAsRoot)

Also available in: Unified diff