uptime-kuma/db/knex_migrations/2025-02-17-2142-generalize-analytics.js
Frank Elsinga 0f61d7ee1b
chore: enable formatting over the entire codebase in CI (#6655)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-09 02:10:36 +01:00

23 lines
932 B
JavaScript

// Udpate status_page table to generalize analytics fields
exports.up = function (knex) {
return knex.schema
.alterTable("status_page", function (table) {
table.renameColumn("google_analytics_tag_id", "analytics_id");
table.string("analytics_script_url");
table.enu("analytics_type", ["google", "umami", "plausible", "matomo"]).defaultTo(null);
})
.then(() => {
// After a succesful migration, add google as default for previous pages
knex("status_page").whereNotNull("analytics_id").update({
analytics_type: "google",
});
});
};
exports.down = function (knex) {
return knex.schema.alterTable("status_page", function (table) {
table.renameColumn("analytics_id", "google_analytics_tag_id");
table.dropColumn("analytics_script_url");
table.dropColumn("analytics_type");
});
};