Files
ingtrakapp/pocketbase/pb_migrations/1740000006_ingtrak_home_widgets_budget.js
T
2026-09-10 17:34:28 +02:00

65 lines
1.5 KiB
JavaScript

/// PocketBase migration: budget / chart / icon fields on home_filter_widgets.
migrate((app) => {
const col = app.findCollectionByNameOrId("home_filter_widgets");
if (!col.fields.getByName("widget_type")) {
col.fields.add(new TextField({
name: "widget_type",
required: false,
max: 40,
}));
}
if (!col.fields.getByName("icon_id")) {
col.fields.add(new TextField({
name: "icon_id",
required: false,
max: 40,
}));
}
if (!col.fields.getByName("chart_style")) {
col.fields.add(new TextField({
name: "chart_style",
required: false,
max: 40,
}));
}
if (!col.fields.getByName("budget_cap_mode")) {
col.fields.add(new TextField({
name: "budget_cap_mode",
required: false,
max: 40,
}));
}
if (!col.fields.getByName("budget_fixed_amount")) {
col.fields.add(new NumberField({
name: "budget_fixed_amount",
required: false,
}));
}
if (!col.fields.getByName("budget_average_months")) {
col.fields.add(new NumberField({
name: "budget_average_months",
required: false,
onlyInt: true,
}));
}
app.save(col);
}, (app) => {
try {
const col = app.findCollectionByNameOrId("home_filter_widgets");
for (const name of [
"widget_type",
"icon_id",
"chart_style",
"budget_cap_mode",
"budget_fixed_amount",
"budget_average_months",
]) {
const field = col.fields.getByName(name);
if (field) col.fields.removeById(field.id);
}
app.save(col);
} catch (_) {}
});