Revision 6460
Added by Aaron Marcuse-Kubitza about 12 years ago
bin/make_analytical_db | ||
---|---|---|
10 | 10 |
|
11 | 11 |
(set -x; date) |
12 | 12 |
|
13 |
mk_analytical_table () |
|
14 |
{ |
|
15 |
local table="$1" |
|
16 |
cat <<EOF |
|
17 |
-- Create $table |
|
18 |
TRUNCATE $table; |
|
19 |
INSERT INTO $table SELECT * FROM ${table}_view; |
|
20 |
|
|
21 |
-- Create analytical_db.$table view pointing to table in $public |
|
22 |
DROP VIEW IF EXISTS analytical_db.$table; |
|
23 |
CREATE VIEW analytical_db.$table AS |
|
24 |
SELECT * FROM "$public".$table; |
|
25 |
GRANT SELECT ON TABLE analytical_db.$table TO bien_read; |
|
26 |
EOF |
|
27 |
} |
|
28 |
|
|
13 | 29 |
(set -x; "$selfDir/psql_verbose_vegbien" <<EOF |
14 | 30 |
TRUNCATE geoscrub_input; |
15 | 31 |
INSERT INTO geoscrub_input SELECT * FROM geoscrub_input_view; |
... | ... | |
18 | 34 |
TRUNCATE threatened_taxonlabel; |
19 | 35 |
INSERT INTO threatened_taxonlabel SELECT * FROM threatened_taxonlabel_view; |
20 | 36 |
|
21 |
TRUNCATE analytical_stem; |
|
22 |
INSERT INTO analytical_stem SELECT * FROM analytical_stem_view; |
|
23 |
TRUNCATE analytical_aggregate; |
|
24 |
INSERT INTO analytical_aggregate SELECT * FROM analytical_aggregate_view; |
|
25 |
|
|
26 |
-- Create analytical_db views pointing to the analytical_* versions in $public |
|
27 |
|
|
28 |
DROP VIEW IF EXISTS analytical_db.analytical_stem; |
|
29 |
CREATE VIEW analytical_db.analytical_stem AS |
|
30 |
SELECT * FROM "$public".analytical_stem; |
|
31 |
GRANT SELECT ON TABLE analytical_db.analytical_stem TO bien_read; |
|
32 |
|
|
33 |
DROP VIEW IF EXISTS analytical_db.analytical_aggregate; |
|
34 |
CREATE VIEW analytical_db.analytical_aggregate AS |
|
35 |
SELECT * FROM "$public".analytical_aggregate; |
|
36 |
GRANT SELECT ON TABLE analytical_db.analytical_aggregate TO bien_read; |
|
37 |
$(mk_analytical_table analytical_stem) |
|
38 |
$(mk_analytical_table analytical_aggregate) |
|
37 | 39 |
EOF |
38 | 40 |
) |
Also available in: Unified diff
make_analytical_db: Factored analytical_* table creation code out into mk_analytical_table() function