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