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