1
|
#!/bin/bash
|
2
|
# :mode=transact-sql:
|
3
|
cd "$(dirname "$0")"
|
4
|
. ../../../lib/import.sh
|
5
|
|
6
|
map_table
|
7
|
psql <<'EOF'
|
8
|
SELECT functions.set_col_types('"SUBPLOT"', ARRAY[
|
9
|
('STATECD', 'integer')
|
10
|
, ('UNITCD', 'integer')
|
11
|
, ('COUNTYCD', 'integer')
|
12
|
, ('locationName', 'integer')
|
13
|
, ('INVYR', 'integer')
|
14
|
, ('subplot', 'integer')
|
15
|
]::functions.col_cast[]);
|
16
|
|
17
|
SELECT functions.create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.ID" UNIQUE ("subplotID")$$);
|
18
|
SELECT functions.create_if_not_exists($$ALTER TABLE "SUBPLOT" ADD CONSTRAINT "SUBPLOT.unique" UNIQUE ("STATECD", "UNITCD", "COUNTYCD", "locationName", "INVYR", "subplot")$$);
|
19
|
SELECT functions.cluster_once('"SUBPLOT"', '"SUBPLOT.unique"');
|