Initial web
This commit is contained in:
19
web/migrations/003_remove_stacked_add_divider.js
Normal file
19
web/migrations/003_remove_stacked_add_divider.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/** @type {import('node-pg-migrate').MigrationBuilder} */
|
||||
exports.up = (pgm) => {
|
||||
pgm.sql(`ALTER TABLE charts DROP CONSTRAINT IF EXISTS charts_viz_type_check`);
|
||||
pgm.sql(`ALTER TABLE charts ADD CONSTRAINT charts_viz_type_check CHECK (viz_type IN ('line','table'))`);
|
||||
|
||||
pgm.sql(`ALTER TABLE charts DROP CONSTRAINT IF EXISTS charts_chart_type_check`);
|
||||
pgm.sql(`ALTER TABLE charts ADD CONSTRAINT charts_chart_type_check CHECK (chart_type IN ('signals','ups','divider'))`);
|
||||
|
||||
// Migrate any existing stacked charts to line
|
||||
pgm.sql(`UPDATE charts SET viz_type = 'line' WHERE viz_type = 'stacked'`);
|
||||
};
|
||||
|
||||
exports.down = (pgm) => {
|
||||
pgm.sql(`ALTER TABLE charts DROP CONSTRAINT IF EXISTS charts_viz_type_check`);
|
||||
pgm.sql(`ALTER TABLE charts ADD CONSTRAINT charts_viz_type_check CHECK (viz_type IN ('line','stacked','table'))`);
|
||||
|
||||
pgm.sql(`ALTER TABLE charts DROP CONSTRAINT IF EXISTS charts_chart_type_check`);
|
||||
pgm.sql(`ALTER TABLE charts ADD CONSTRAINT charts_chart_type_check CHECK (chart_type IN ('signals','ups'))`);
|
||||
};
|
||||
Reference in New Issue
Block a user