1 |
8163
|
aaronmk
|
#!/bin/bash
|
2 |
|
|
# :mode=transact-sql:
|
3 |
|
|
cd "$(dirname "$0")"
|
4 |
|
|
. ../../../lib/import.sh
|
5 |
|
|
|
6 |
8164
|
aaronmk
|
map_table
|
7 |
8163
|
aaronmk
|
psql <<'EOF'
|
8 |
8184
|
aaronmk
|
SELECT set_col_types('"TREE"', ARRAY[
|
9 |
8172
|
aaronmk
|
('STATECD', 'integer')
|
10 |
|
|
, ('UNITCD', 'integer')
|
11 |
8170
|
aaronmk
|
, ('COUNTYCD', 'integer')
|
12 |
8172
|
aaronmk
|
, ('locationName', 'integer')
|
13 |
|
|
, ('INVYR', 'integer')
|
14 |
|
|
, ('subplot', 'integer')
|
15 |
|
|
, ('authorEventCode', 'integer')
|
16 |
|
|
, ('SPCD', 'integer')
|
17 |
8184
|
aaronmk
|
]::col_cast[]);
|
18 |
8110
|
aaronmk
|
|
19 |
8172
|
aaronmk
|
-- ("STATECD", "UNITCD", "COUNTYCD", "locationName", "INVYR", "authorEventCode", "subplot", "TREE", "STATUSCD") is not ID
|
20 |
8184
|
aaronmk
|
SELECT create_if_not_exists($$ALTER TABLE "TREE" ADD CONSTRAINT "TREE.ID" UNIQUE ("individualObservationID")$$);
|
21 |
|
|
SELECT cluster_once('"TREE"', '"TREE.ID"');
|
22 |
8099
|
aaronmk
|
|
23 |
8184
|
aaronmk
|
SELECT create_if_not_exists($$CREATE INDEX "TREE.parent" ON "TREE" ("STATECD", "UNITCD", "COUNTYCD", "locationName", "INVYR", "authorEventCode", "subplot")$$);
|