Project

General

Profile

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 8136 aaronmk
SELECT functions.set_col_types('"PLOT"', ARRAY[
9 8172 aaronmk
  ('STATECD', 'integer')
10
, ('UNITCD', 'integer')
11 8170 aaronmk
, ('COUNTYCD', 'integer')
12 8172 aaronmk
, ('locationName', 'integer')
13
, ('INVYR', 'integer')
14 8110 aaronmk
]::functions.col_cast[]);
15
16 8172 aaronmk
SELECT functions.create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.ID"     UNIQUE ("locationID")$$);
17
SELECT functions.create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.unique" UNIQUE ("STATECD", "UNITCD", "COUNTYCD", "locationName", "INVYR")$$);
18 8136 aaronmk
SELECT functions.cluster_once('"PLOT"', '"PLOT.unique"');