forked from CartoDB/CartoDB-basemaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to generate the SQL to refresh the materialized views
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Converts yaml to sql | ||
|
||
var yaml = require('js-yaml'); | ||
var fs = require('fs'); | ||
|
||
function tname(table_name) { | ||
return table_name; | ||
} | ||
|
||
|
||
// Write SQL to STDOUT | ||
var doc = yaml.safeLoad(fs.readFileSync('generalizations.yml', 'utf8')); | ||
console.log("SET client_min_messages TO WARNING;"); | ||
console.log("SET statement_timeout = 0;\n") | ||
doc.forEach(function(view) { | ||
// Regular views require no refreshing | ||
if (view.materialized) { | ||
console.log("REFRESH MATERIALIZED VIEW CONCURRENTLY " + tname(view.name) + ";"); | ||
} | ||
}); | ||
console.log("\nRESET client_min_messages;"); | ||
|