1 |
8163
|
aaronmk
|
#!/bin/bash
|
2 |
|
|
# :mode=transact-sql:
|
3 |
|
|
cd "$(dirname "$0")"
|
4 |
|
|
. ../../../lib/import.sh
|
5 |
|
|
|
6 |
|
|
psql <<'EOF'
|
7 |
8136
|
aaronmk
|
SELECT functions.to_global_col_names('"COUNTY"');
|
8 |
8124
|
aaronmk
|
|
9 |
|
|
SELECT functions.rename_if_exists($$ALTER TABLE "COUNTY" RENAME "COUNTY.STATECD" TO ".STATECD" $$);
|
10 |
|
|
SELECT functions.rename_if_exists($$ALTER TABLE "COUNTY" RENAME "COUNTY.UNITCD" TO ".UNITCD" $$);
|
11 |
|
|
SELECT functions.rename_if_exists($$ALTER TABLE "COUNTY" RENAME "COUNTY.COUNTYCD" TO ".COUNTYCD"$$);
|
12 |
|
|
|
13 |
8136
|
aaronmk
|
SELECT functions.set_col_types('"COUNTY"', ARRAY[
|
14 |
8124
|
aaronmk
|
('.STATECD' , 'integer')
|
15 |
|
|
, ('.UNITCD' , 'integer')
|
16 |
|
|
, ('.COUNTYCD', 'integer')
|
17 |
|
|
]::functions.col_cast[]);
|
18 |
|
|
|
19 |
8130
|
aaronmk
|
SELECT functions.create_if_not_exists($$ALTER TABLE "COUNTY" ADD CONSTRAINT "COUNTY.ID" UNIQUE ("COUNTY.CN") $$);
|
20 |
8124
|
aaronmk
|
SELECT functions.create_if_not_exists($$ALTER TABLE "COUNTY" ADD CONSTRAINT "COUNTY.unique" UNIQUE (".STATECD", ".UNITCD", ".COUNTYCD")$$);
|