Project

General

Profile

1 702 aaronmk
Installation:
2 8458 aaronmk
	Check out svn: svn co https://code.nceas.ucsb.edu/code/projects/bien
3
	cd bien/
4
	Install: make install
5
		WARNING: This will delete the current public schema of your VegBIEN DB!
6
	Uninstall: make uninstall
7
		WARNING: This will delete your entire VegBIEN DB!
8
		This includes all archived imports and staging tables.
9 554 aaronmk
10 3674 aaronmk
Maintenance:
11 9399 aaronmk
	on a live machine, you should put the following in your .profile:
12
		umask ug=rwx,o= # prevent files from becoming web-accessible
13 9400 aaronmk
		unset TMOUT # TMOUT causes screen to exit even with background processes
14 10379 aaronmk
	if http://vegbiendev.nceas.ucsb.edu/phppgadmin/ goes down:
15
		on vegbiendev: make postgres-Linux
16 8459 aaronmk
	to synchronize vegbiendev, jupiter, and your local machine:
17 9886 aaronmk
		WARNING: pay careful attention to all files that will be deleted or
18
			overwritten!
19 8460 aaronmk
		install put if needed:
20
			download https://uutils.googlecode.com/svn/trunk/bin/put to ~/bin/ and `chmod +x` it
21 8459 aaronmk
		when changes are made on vegbiendev:
22 10816 aaronmk
			on all machines: ./fix_perms
23 8459 aaronmk
			on vegbiendev, upload:
24 10032 aaronmk
				overwrite=1 bin/sync_upload
25 10029 aaronmk
					then rerun with l=1 ...
26 8459 aaronmk
			on your machine, download:
27 10040 aaronmk
				overwrite=1 swap=1 src=. dest='aaronmk@jupiter:~/bien' put --exclude=.svn inputs/VegBIEN/TWiki
28 10029 aaronmk
					then rerun with l=1 ...
29 10032 aaronmk
				overwrite=1 swap=1 bin/sync_upload
30 10029 aaronmk
					then rerun with l=1 ...
31 10814 aaronmk
				make backups/TNRS.backup/download live=1
32 10093 aaronmk
				overwrite=1 sync_remote_url=~/Dropbox/svn/ bin/sync_upload --existing --size-only # just update mtimes/perms
33 10068 aaronmk
					then rerun with l=1 ...
34 8462 aaronmk
	to synchronize a Mac's settings with my testing machine's:
35
		download:
36
			WARNING: this will overwrite all your user's settings!
37 10040 aaronmk
			overwrite=1 swap=1 sync_local_dir=~/Library/ sync_remote_subdir=Library/ bin/sync_upload --exclude="/Saved Application State"
38 10029 aaronmk
				then rerun with l=1 ...
39 8462 aaronmk
		upload:
40 8719 aaronmk
			do step when changes are made on vegbiendev > on your machine, download
41 10812 aaronmk
			on jupiter: (cd ~/Dropbox/svn/; up)
42 10035 aaronmk
			on your machine:
43 10040 aaronmk
				overwrite=1 del= sync_local_dir=~/Dropbox/svn/ sync_remote_subdir=Dropbox/svn/ bin/sync_upload --size-only # just update mtimes
44 10035 aaronmk
					then rerun with l=1 ...
45 10818 aaronmk
				overwrite=1      sync_local_dir=~              sync_remote_subdir=             bin/sync_upload --exclude="/Library/Saved Application State" --exclude="/.Trash" --exclude="/bin" --exclude="/bin/pg_ctl" --exclude="/bin/unzip" --exclude="/Dropbox/home" --exclude="/.profile" --exclude="/.shrc" --exclude="/.bashrc"
46 10035 aaronmk
					then rerun with l=1 ...
47 10040 aaronmk
				overwrite=1      sync_local_dir=~              sync_remote_url=~/Dropbox/home  bin/sync_upload --exclude="/Library/Saved Application State" --exclude="/.Trash" --exclude="/.dropbox" --exclude="/Documents/BIEN" --exclude="/Dropbox" --exclude="/software" --exclude="/VirtualBox VMs/**.sav" --exclude="/VirtualBox VMs/**.vdi" --exclude="/VirtualBox VMs/**.vmdk"
48 10035 aaronmk
					then rerun with l=1 ...
49 10221 aaronmk
		upload just the VirtualBox VMs:
50
			on your machine:
51
				overwrite=1      sync_local_dir=~              sync_remote_subdir=             bin/sync_upload ~/"VirtualBox VMs/**"
52
					then rerun with l=1 ...
53 8720 aaronmk
	to backup files not in Time Machine:
54 10817 aaronmk
		pg_ctl. stop # stop the PostgreSQL server
55 10029 aaronmk
		src=/ dest=/Volumes/Time\ Machine\ Backups/ sudo put Library/PostgreSQL/9.1/data/
56
			then rerun with l=1 ...
57 8720 aaronmk
		start the PostgreSQL server
58 8458 aaronmk
	VegCore data dictionary:
59
		Regularly, or whenever the VegCore data dictionary page
60
			(https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore)
61
			is changed, regenerate mappings/VegCore.csv:
62
			make mappings/VegCore.htm-remake; make mappings/
63
			svn di mappings/VegCore.tables.redmine
64
			If there are changes, update the data dictionary's Tables section
65
			When moving terms, check that no terms were lost: svn di
66 10286 aaronmk
			svn ci -m 'mappings/VegCore.htm: regenerated from wiki'
67 8458 aaronmk
	Important: Whenever you install a system update that affects PostgreSQL or
68
		any of its dependencies, such as libc, you should restart the PostgreSQL
69
		server. Otherwise, you may get strange errors like "the database system
70
		is in recovery mode" which go away upon reimport, or you may not be able
71
		to access the database as the postgres superuser. This applies to both
72
		Linux and Mac OS X.
73 3674 aaronmk
74 7287 aaronmk
Single datasource import:
75 10804 aaronmk
	(Re)import and scrub: make inputs/<datasrc>/reimport_scrub by_col=1 &
76
	(Re)import only: make inputs/<datasrc>/reimport by_col=1 &
77
	(Re)scrub: make inputs/<datasrc>/rescrub by_col=1 &
78 8458 aaronmk
	Note that these commands also work if the datasource is not yet imported
79 7287 aaronmk
80
Full database import:
81 9499 aaronmk
	WARNING: You must perform *every single* step listed below, to avoid
82
		breaking column-based import
83 9883 aaronmk
	On jupiter: svn up --force
84 8458 aaronmk
	On local machine:
85 9887 aaronmk
		do steps under Maintenance > "to synchronize vegbiendev, jupiter, and
86
			your local machine" above
87 8458 aaronmk
		make inputs/upload
88 10025 aaronmk
		make inputs/upload live=1
89 8458 aaronmk
		make test by_col=1
90 10549 aaronmk
			if you encounter errors, they are most likely related to the
91
				PostgreSQL error parsing in /lib/sql.py parse_exception()
92 8458 aaronmk
			See note under Testing below
93
	On vegbiendev:
94
	Ensure there are no local modifications: svn st
95
	svn up
96
	make inputs/download
97 10025 aaronmk
	make inputs/download live=1
98 8458 aaronmk
	For each newly-uploaded datasource above: make inputs/<datasrc>/reinstall
99
	Update the auxiliary schemas: make schemas/reinstall
100
		The public schema will be installed separately by the import process
101
	Delete imports before the last so they won't bloat the full DB backup:
102
		make backups/vegbien.<version>.backup/remove
103
		To keep a previous import other than the public schema:
104
			export dump_opts='--exclude-schema=public --exclude-schema=<version>'
105 9970 aaronmk
	Make sure there is at least 300GB of disk space on /: df -h
106 10603 aaronmk
		The import schema is 230GB, and may use additional space for temp tables
107 8458 aaronmk
		To free up space, remove backups that have been archived on jupiter:
108
			List backups/ to view older backups
109
			Check their MD5 sums using the steps under On jupiter below
110
			Remove these backups
111 9899 aaronmk
	Remove any leftover TNRS lockfile: rm inputs/.TNRS/tnrs/tnrs.make.lock
112
		Usually, the PID in it would not exist, but sometimes it now refers to
113
			a different, active process which blocks tnrs.make
114 8458 aaronmk
	screen
115
	Press ENTER
116 9531 aaronmk
	set -o ignoreeof #prevent Ctrl+D from exiting `screen` to keep attached jobs
117 9532 aaronmk
	unset TMOUT # TMOUT causes screen to exit even with background processes
118
	unset version
119 10579 aaronmk
	Start column-based import: . bin/import_all
120
		To use row-based import: . bin/import_all by_col=
121 8458 aaronmk
		To stop all running imports: . bin/stop_imports
122
		WARNING: Do NOT run import_all in the background, or the jobs it creates
123
			won't be owned by your shell.
124
		Note that import_all will take up to an hour to import the NCBI backbone
125
			and other metadata before returning control to the shell.
126
	Wait (overnight) for the import to finish
127
	To recover from a closed terminal window: screen -r
128 10583 aaronmk
	To restart an aborted import for a specific table:
129
		export version=<version>
130 10584 aaronmk
		make inputs/<datasrc>/<table>/import_scrub by_col=1 continue=1 &
131 10588 aaronmk
		bin/after_import $! & # $! can also be obtained from `jobs -l`
132 8458 aaronmk
	Get $version: echo $version
133
	Set $version in all vegbiendev terminals: export version=<version>
134 10557 aaronmk
	When there are no more running jobs, exit the screen
135 10025 aaronmk
	Upload logs (run on vegbiendev): make inputs/upload live=1
136
	On local machine: make inputs/download-logs live=1
137 8458 aaronmk
	In PostgreSQL:
138
		Check that the provider_count and source tables contain entries for all
139
			inputs
140 9492 aaronmk
	Check that TNRS ran successfully:
141
		tail -100 inputs/.TNRS/tnrs/logs/tnrs.make.log.sql
142
		If the log ends in an AssertionError
143
			"assert sql.table_col_names(db, table) == header":
144
			Figure out which TNRS CSV columns have changed
145
			On local machine:
146 10784 aaronmk
				Make the changes in the DB's TNRS and public schemas
147
				rm=1 inputs/.TNRS/schema.sql.run export_
148 9492 aaronmk
				make schemas/remake
149 10785 aaronmk
				inputs/test_taxonomic_names/test_scrub # re-run TNRS
150 10784 aaronmk
				rm=1 inputs/.TNRS/data.sql.run export_
151 9492 aaronmk
				Commit
152
			On vegbiendev:
153
				If dropping a column, save the dependent views
154
				Make the same changes in the live TNRS.tnrs table on vegbiendev
155
				If dropping a column, recreate the dependent views
156
				Restart the TNRS client: make scrub by_col=1 &
157 8458 aaronmk
	tail inputs/{.,}*/*/logs/$version.log.sql
158
	In the output, search for "Command exited with non-zero status"
159
	For inputs that have this, fix the associated bug(s)
160
	If many inputs have errors, discard the current (partial) import:
161
		make schemas/$version/uninstall
162
	Otherwise, continue
163 9498 aaronmk
	Publish the new import:
164
		WARNING: Before proceeding, be sure you have done *every single*
165
			verification step listed above. Otherwise, a previous valid import
166
			could incorrectly be overwritten with a broken one.
167
		make schemas/$version/publish
168 8458 aaronmk
	unset version
169
	backups/fix_perms
170 10027 aaronmk
	make backups/upload live=1
171 8458 aaronmk
	On jupiter:
172
		cd /data/dev/aaronmk/bien/backups
173
		For each newly-archived backup:
174
			make -s <backup>.md5/test
175
			Check that "OK" is printed next to the filename
176
	On nimoy:
177
		cd /home/bien/svn/
178
		svn up
179
		export version=<version>
180
		make backups/analytical_stem.$version.csv/download
181
		In the bien_web DB:
182
			Create the analytical_stem_<version> table using its schema
183
				in schemas/vegbien.my.sql
184
		make -s backups/analytical_stem.$version.csv.md5/test
185
		Check that "OK" is printed next to the filename
186 10029 aaronmk
		table=analytical_stem_$version bin/publish_analytical_db \
187 8458 aaronmk
			backups/analytical_stem.$version.csv
188
	If desired, record the import times in inputs/import.stats.xls:
189
		Open inputs/import.stats.xls
190
		If the rightmost import is within 5 columns of column IV:
191
			Copy the current tab to <leftmost-date>~<rightmost-date>
192
			Remove the previous imports from the current tab because they are
193
				now in the copied tab instead
194
		Insert a copy of the leftmost "By column" column group before it
195
		export version=<version>
196
		bin/import_date inputs/{.,}*/*/logs/$version.log.sql
197
		Update the import date in the upper-right corner
198
		bin/import_times inputs/{.,}*/*/logs/$version.log.sql
199
		Paste the output over the # Rows/Time columns, making sure that the
200
			row counts match up with the previous import's row counts
201
		If the row counts do not match up, insert or reorder rows as needed
202
			until they do. Get the datasource names from the log file footers:
203
			tail inputs/{.,}*/*/logs/$version.log.sql
204
		Commit: svn ci -m "inputs/import.stats.xls: Updated import times"
205 9497 aaronmk
	To run TNRS:
206 9996 aaronmk
		To use an import other than public: export version=<version>
207 9995 aaronmk
		make scrub &
208 8458 aaronmk
		To view progress:
209
			tail -100 inputs/.TNRS/tnrs/logs/tnrs.make.log.sql
210 9497 aaronmk
	To remake analytical DB:
211 9996 aaronmk
		To use an import other than public: export version=<version>
212 9497 aaronmk
		bin/make_analytical_db &
213 8458 aaronmk
		To view progress:
214 10600 aaronmk
			tail -150 inputs/analytical_db/logs/make_analytical_db.log.sql
215 8458 aaronmk
	To back up DB (staging tables and last import):
216 10578 aaronmk
		To use an import *other than public*: export version=<version>
217 10743 aaronmk
		make backups/TNRS.backup-remake &
218 10577 aaronmk
		dump_opts=--exclude-schema=public make backups/vegbien.$version.backup/test &
219 10578 aaronmk
			If after renaming to public, instead set dump_opts='' and replace
220
			$version with the appropriate revision
221 10744 aaronmk
		make backups/upload live=1
222 3381 aaronmk
223 3545 aaronmk
Backups:
224 8458 aaronmk
	Archived imports:
225
		Back up: make backups/<version>.backup &
226
			Note: To back up the last import, you must archive it first:
227
				make schemas/rotate
228
		Test: make -s backups/<version>.backup/test &
229
		Restore: make backups/<version>.backup/restore &
230
		Remove: make backups/<version>.backup/remove
231 10028 aaronmk
		Download: make backups/<version>.backup/download
232 8458 aaronmk
	TNRS cache:
233
		Back up: make backups/TNRS.backup-remake &
234 10010 aaronmk
			runtime: 3 min ("real 2m48.859s")
235 8458 aaronmk
		Restore:
236
			yes|make inputs/.TNRS/uninstall
237
			make backups/TNRS.backup/restore &
238 10010 aaronmk
				runtime: 5.5 min ("real 5m35.829s")
239 8458 aaronmk
			yes|make schemas/public/reinstall
240
				Must come after TNRS restore to recreate tnrs_input_name view
241
	Full DB:
242
		Back up: make backups/vegbien.<version>.backup &
243
		Test: make -s backups/vegbien.<version>.backup/test &
244
		Restore: make backups/vegbien.<version>.backup/restore &
245 10028 aaronmk
		Download: make backups/vegbien.<version>.backup/download
246 8458 aaronmk
	Import logs:
247 10025 aaronmk
		Download: make inputs/download-logs live=1
248 554 aaronmk
249 1773 aaronmk
Datasource setup:
250 8469 aaronmk
	umask ug=rwx,o= # prevent files from becoming web-accessible
251 8458 aaronmk
	Add a new datasource: make inputs/<datasrc>/add
252
		<datasrc> may not contain spaces, and should be abbreviated.
253
		If the datasource is a herbarium, <datasrc> should be the herbarium code
254
			as defined by the Index Herbariorum <http://sweetgum.nybg.org/ih/>
255
	For MySQL inputs (exports and live DB connections):
256
		For .sql exports:
257
			Place the original .sql file in _src/ (*not* in _MySQL/)
258
			Follow the steps starting with Install the staging tables below.
259
				This is for an initial sync to get the file onto vegbiendev.
260
			On vegbiendev:
261
				Create a database for the MySQL export in phpMyAdmin
262 9494 aaronmk
				Give the bien user all database-specific privileges *except*
263
					UPDATE, DELETE, ALTER, DROP. This prevents bugs in the
264
					import scripts from accidentally deleting data.
265 8458 aaronmk
				bin/mysql_bien database <inputs/<datasrc>/_src/export.sql &
266
		mkdir inputs/<datasrc>/_MySQL/
267
		cp -p lib/MySQL.{data,schema}.sql.make inputs/<datasrc>/_MySQL/
268
		Edit _MySQL/*.make for the DB connection
269
			For a .sql export, use server=vegbiendev and --user=bien
270
		Skip the Add input data for each table section
271
	For MS Access databases:
272
		Place the .mdb or .accdb file in _src/
273
		Download and install Access To PostgreSQL from
274
			http://www.bullzip.com/download.php
275
		Use Access To PostgreSQL to export the database:
276
			Export just the tables/indexes to inputs/<datasrc>/<file>.schema.sql
277
			Export just the data to inputs/<datasrc>/<file>.data.sql
278
		In <file>.schema.sql, make the following changes:
279
			Replace text "BOOLEAN" with "/*BOOLEAN*/INTEGER"
280
			Replace text "DOUBLE PRECISION NULL" with "DOUBLE PRECISION"
281
		Skip the Add input data for each table section
282
	Add input data for each table present in the datasource:
283
		For .sql exports, you must use the name of the table in the DB export
284
		For CSV files, you can use any name. It's recommended to use a table
285
			name from <https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCSV#Suggested-table-names>
286
		Note that if this table will be joined together with another table, its
287
			name must end in ".src"
288
		make inputs/<datasrc>/<table>/add
289
			Important: DO NOT just create an empty directory named <table>!
290
				This command also creates necessary subdirs, such as logs/.
291
		If the table is in a .sql export: make inputs/<datasrc>/<table>/install
292
			Otherwise, place the CSV(s) for the table in
293
			inputs/<datasrc>/<table>/ OR place a query joining other tables
294
			together in inputs/<datasrc>/<table>/create.sql
295
		Important: When exporting relational databases to CSVs, you MUST ensure
296
			that embedded quotes are escaped by doubling them, *not* by
297
			preceding them with a "\" as is the default in phpMyAdmin
298
		If there are multiple part files for a table, and the header is repeated
299
			in each part, make sure each header is EXACTLY the same.
300 8466 aaronmk
			(If the headers are not the same, the CSV concatenation script
301
			assumes the part files don't have individual headers and treats the
302
			subsequent headers as data rows.)
303 8458 aaronmk
		Add <table> to inputs/<datasrc>/import_order.txt before other tables
304
			that depend on it
305
	Install the staging tables:
306
		make inputs/<datasrc>/reinstall quiet=1 &
307
		For a MySQL .sql export:
308
			At prompt "[you]@vegbiendev's password:", enter your password
309
			At prompt "Enter password:", enter the value in config/bien_password
310
		To view progress: tail -f inputs/<datasrc>/<table>/logs/install.log.sql
311
		View the logs: tail -n +1 inputs/<datasrc>/*/logs/install.log.sql
312
			tail provides a header line with the filename
313
			+1 starts at the first line, to show the whole file
314
		For every file with an error 'column "..." specified more than once':
315
			Add a header override file "+header.<ext>" in <table>/:
316
				Note: The leading "+" should sort it before the flat files.
317
					"_" unfortunately sorts *after* capital letters in ASCII.
318
				Create a text file containing the header line of the flat files
319
				Add an ! at the beginning of the line
320
					This signals cat_csv that this is a header override.
321
				For empty names, use their 0-based column # (by convention)
322
				For duplicate names, add a distinguishing suffix
323
				For long names that collided, rename them to <= 63 chars long
324
				Do NOT make readability changes in this step; that is what the
325
					map spreadsheets (below) are for.
326
				Save
327
		If you made any changes, re-run the install command above
328
	Auto-create the map spreadsheets: make inputs/<datasrc>/
329
	Map each table's columns:
330
		In each <table>/ subdir, for each "via map" map.csv:
331
			Open the map in a spreadsheet editor
332
			Open the "core map" /mappings/Veg+-VegBIEN.csv
333
			In each row of the via map, set the right column to a value from the
334
				left column of the core map
335
			Save
336
		Regenerate the derived maps: make inputs/<datasrc>/
337
	Accept the test cases:
338
		make inputs/<datasrc>/test
339
			When prompted to "Accept new test output", enter y and press ENTER
340
			If you instead get errors, do one of the following for each one:
341
			-	If the error was due to a bug, fix it
342
			-	Add a SQL function that filters or transforms the invalid data
343
			-	Make an empty mapping for the columns that produced the error.
344
				Put something in the Comments column of the map spreadsheet to
345
				prevent the automatic mapper from auto-removing the mapping.
346
			When accepting tests, it's helpful to use WinMerge
347
				(see WinMerge setup below for configuration)
348
		make inputs/<datasrc>/test by_col=1
349
			If you get errors this time, this always indicates a bug, usually in
350
				the VegBIEN unique constraints or column-based import itself
351
	Add newly-created files: make inputs/<datasrc>/add
352
	Commit: svn ci -m "Added inputs/<datasrc>/" inputs/<datasrc>/
353
	Update vegbiendev:
354
		On jupiter: svn up
355
		On local machine:
356
			./fix_perms
357
			make inputs/upload
358 10025 aaronmk
			make inputs/upload live=1
359 8458 aaronmk
		On vegbiendev:
360
			svn up
361
			make inputs/download
362 10025 aaronmk
			make inputs/download live=1
363 8458 aaronmk
			Follow the steps under Install the staging tables above
364 1773 aaronmk
365 6484 aaronmk
Datasource refreshing:
366 8458 aaronmk
	VegBank:
367
		make inputs/VegBank/vegbank.sql-remake
368
		make inputs/VegBank/reinstall quiet=1 &
369 6484 aaronmk
370 702 aaronmk
Schema changes:
371 8458 aaronmk
	When changing the analytical views, run sync_analytical_..._to_view()
372
		to update the corresponding table
373
	Remember to update the following files with any renamings:
374
		schemas/filter_ERD.csv
375
		mappings/VegCore-VegBIEN.csv
376
		mappings/verify.*.sql
377
	Regenerate schema from installed DB: make schemas/remake
378
	Reinstall DB from schema: make schemas/public/reinstall schemas/reinstall
379
		WARNING: This will delete the current public schema of your VegBIEN DB!
380 8837 aaronmk
	Reinstall staging tables:
381
		On local machine:
382 8840 aaronmk
			sudo -E -u postgres psql <<<'ALTER DATABASE vegbien RENAME TO vegbien_prev'
383 8845 aaronmk
			make db
384 8837 aaronmk
			. bin/reinstall_all
385
			Fix any bugs and retry until no errors
386 8846 aaronmk
			make schemas/public/install
387
				This must be run *after* the datasources are installed, because
388
				views in public depend on some of the datasources
389 8842 aaronmk
			sudo -E -u postgres psql <<<'DROP DATABASE vegbien_prev'
390 8841 aaronmk
		On vegbiendev: repeat the above steps
391 8837 aaronmk
			WARNING: Do not run this until reinstall_all runs successfully on
392
			the local machine, or the live DB may be unrestorable!
393 8458 aaronmk
	Sync ERD with vegbien.sql schema:
394
		Run make schemas/vegbien.my.sql
395
		Open schemas/vegbien.ERD.mwb in MySQLWorkbench
396
		Go to File > Export > Synchronize With SQL CREATE Script...
397
		For Input File, select schemas/vegbien.my.sql
398
		Click Continue
399
		In the changes list, select each table with an arrow next to it
400
		Click Update Model
401
		Click Continue
402
		Note: The generated SQL script will be empty because we are syncing in
403
			the opposite direction
404
		Click Execute
405
		Reposition any lines that have been reset
406
		Add any new tables by dragging them from the Catalog in the left sidebar
407
			to the diagram
408
		Remove any deleted tables by right-clicking the table's diagram element,
409
			selecting Delete '<table name>', and clicking Delete
410
		Save
411
		If desired, update the graphical ERD exports (see below)
412
	Update graphical ERD exports:
413
		Go to File > Export > Export as PNG...
414
		Select schemas/vegbien.ERD.png and click Save
415
		Go to File > Export > Export as SVG...
416
		Select schemas/vegbien.ERD.svg and click Save
417
		Go to File > Export > Export as Single Page PDF...
418
		Select schemas/vegbien.ERD.1_pg.pdf and click Save
419
		Go to File > Print...
420
		In the lower left corner, click PDF > Save as PDF...
421
		Set the Title and Author to ""
422
		Select schemas/vegbien.ERD.pdf and click Save
423
		Commit: svn ci -m "schemas/vegbien.ERD.mwb: Regenerated exports"
424
	Refactoring tips:
425
		To rename a table:
426
			In vegbien.sql, do the following:
427
				Replace regexp (?<=_|\b)<old>(?=_|\b) with <new>
428
					This is necessary because the table name is *everywhere*
429
				Search for <new>
430
				Manually change back any replacements inside comments
431
		To rename a column:
432
			Rename the column: ALTER TABLE <table> RENAME <old> TO <new>;
433
			Recreate any foreign key for the column, removing CONSTRAINT <name>
434
				This resets the foreign key name using the new column name
435
	Creating a poster of the ERD:
436
		Determine the poster size:
437
			Measure the line height (from the bottom of one line to the bottom
438
				of another): 16.3cm/24 lines = 0.679cm
439
			Measure the height of the ERD: 35.4cm*2 = 70.8cm
440
			Zoom in as far as possible
441
			Measure the height of a capital letter: 3.5mm
442
			Measure the line height: 8.5mm
443
			Calculate the text's fraction of the line height: 3.5mm/8.5mm = 0.41
444
			Calculate the text height: 0.679cm*0.41 = 0.28cm
445
			Calculate the text height's fraction of the ERD height:
446
				0.28cm/70.8cm = 0.0040
447
			Measure the text height on the *VegBank* ERD poster: 5.5mm = 0.55cm
448
			Calculate the VegBIEN poster height to make the text the same size:
449
				0.55cm/0.0040 = 137.5cm H; *1in/2.54cm = 54.1in H
450
			The ERD aspect ratio is 11 in W x (2*8.5in H) = 11x17 portrait
451
			Calculate the VegBIEN poster width: 54.1in H*11W/17H = 35.0in W
452
			The minimum VegBIEN poster size is 35x54in portrait
453
		Determine the cost:
454
			The FedEx Kinkos near NCEAS (1030 State St, Santa Barbara, CA 93101)
455
				charges the following for posters:
456
				base: $7.25/sq ft
457
				lamination: $3/sq ft
458
				mounting on a board: $8/sq ft
459 203 aaronmk
460 1459 aaronmk
Testing:
461 8458 aaronmk
	On a development machine, you should put the following in your .profile:
462 8469 aaronmk
		umask ug=rwx,o= # prevent files from becoming web-accessible
463 8458 aaronmk
		export log= n=2
464
	Mapping process: make test
465
		Including column-based import: make test by_col=1
466
			If the row-based and column-based imports produce different inserted
467
			row counts, this usually means that a table is underconstrained
468
			(the unique indexes don't cover all possible rows).
469
			This can occur if you didn't use COALESCE(field, null_value) around
470
			a nullable field in a unique index. See sql_gen.null_sentinels for
471
			the appropriate null value to use.
472
	Map spreadsheet generation: make remake
473
	Missing mappings: make missing_mappings
474
	Everything (for most complete coverage): make test-all
475 702 aaronmk
476 7183 aaronmk
Debugging:
477 8458 aaronmk
	"Binary chop" debugging:
478
		(This is primarily useful for regressions that occurred in a previous
479
		revision, which was committed without running all the tests)
480
		svn up -r <rev>; make inputs/.TNRS/reinstall; make schemas/public/reinstall; make <failed-test>.xml
481 8470 aaronmk
	.htaccess:
482
		mod_rewrite:
483 8471 aaronmk
			IMPORTANT: whenever you change the DirectorySlash setting for a
484
				directory, you *must* clear your browser's cache to ensure that
485
				a cached redirect is not used. this is because RewriteRule
486
				redirects are (by default) temporary, but DirectorySlash
487
				redirects are permanent.
488 8470 aaronmk
				for Firefox:
489
					press Cmd+Shift+Delete
490
					check only Cache
491
					press Enter or click Clear Now
492 7183 aaronmk
493 3783 aaronmk
WinMerge setup:
494 8458 aaronmk
	Install WinMerge from <http://winmerge.org/>
495
	Open WinMerge
496
	Go to Edit > Options and click Compare in the left sidebar
497
	Enable "Moved block detection", as described at
498
		<http://manual.winmerge.org/Configuration.html#d0e5892>.
499
	Set Whitespace to Ignore change, as described at
500
		<http://manual.winmerge.org/Configuration.html#d0e5758>.
501 3783 aaronmk
502 3133 aaronmk
Documentation:
503 8458 aaronmk
	To generate a Redmine-formatted list of steps for column-based import:
504
		make schemas/public/reinstall
505
		make inputs/ACAD/Specimen/logs/steps.by_col.log.sql
506
	To import and scrub just the test taxonomic names:
507
		inputs/test_taxonomic_names/test_scrub
508 3133 aaronmk
509 702 aaronmk
General:
510 8458 aaronmk
	To see a program's description, read its top-of-file comment
511
	To see a program's usage, run it without arguments
512
	To remake a directory: make <dir>/remake
513
	To remake a file: make <file>-remake