Revision 4449
Added by Aaron Marcuse-Kubitza about 12 years ago
input.Makefile | ||
---|---|---|
203 | 203 |
%.sql: _MySQL/%.sql |
204 | 204 |
$(bin)/my2pg <$< >$@ |
205 | 205 |
|
206 |
cleanup = (prefix=; . $(bin)/vegbien_dest; env schema=$(datasrc) table=$*\ |
|
207 |
$(bin)/csv2db) |
|
208 |
|
|
209 |
define exportHeader |
|
210 |
$(cleanup) |
|
211 |
echo 'SELECT * FROM "$(datasrc)"."$*" LIMIT 0;'|$(psqlAsBien) \ |
|
212 |
--no-align --field-separator=, --pset=footer=off >$*/header.csv |
|
213 |
endef |
|
214 |
|
|
206 | 215 |
# For staging tables which are derived by joining together other staging tables. |
207 | 216 |
%/install %/header.csv: %/create.sql _always |
208 | 217 |
($(inDatasrc); echo 'CREATE TABLE "$*" AS'; cat $<; echo ';'; \ |
209 | 218 |
echo 'ALTER TABLE "$*" ADD COLUMN row_num serial NOT NULL PRIMARY KEY;'; \ |
210 | 219 |
echo 'VACUUM ANALYZE "$*";')|$(psqlAsBien) --echo-all |
211 |
(prefix=; . $(bin)/vegbien_dest; env schema=$(datasrc) table=$* \ |
|
212 |
$(bin)/csv2db) |
|
213 |
echo 'SELECT * FROM "$(datasrc)"."$*" LIMIT 0;'|$(psqlAsBien) \ |
|
214 |
--no-align --field-separator=, --pset=footer=off >$*/header.csv |
|
220 |
$(exportHeader) |
|
215 | 221 |
|
216 | 222 |
# The joined tables must be suffixed with ".src" to prevent the creation of a |
217 | 223 |
# row_num column, which collides during joins. |
Also available in: Unified diff
input.Makefile: Staging tables installation: `%/install: %/create.sql`: Factored out cleanup and header export operations for reuse in other types of table subdirs