Files
time_tracker/backend/pb_migrations/1736616000_update_time_entries.js
Kris Forbes 493ea4688c
All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 2m17s
Initial commit
2026-01-11 18:55:03 -05:00

46 lines
1.3 KiB
JavaScript

migrate((db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("time_entries");
// Add is_banked field
collection.schema.addField(new SchemaField({
name: "is_banked",
type: "bool",
required: false, // Default true handled in app logic or ignored for now
options: {}
}));
// Add manual_override field
collection.schema.addField(new SchemaField({
name: "manual_override",
type: "bool",
required: false,
options: {}
}));
// Add calculated_hours field
collection.schema.addField(new SchemaField({
name: "calculated_hours",
type: "number",
required: false,
options: {
min: null,
max: null,
noDecimal: false
}
}));
return dao.saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("time_entries");
// logic to remove fields if needed, usually tricky in PB migrations securely without losing data
// For now we just return null or attempt simple removal
collection.schema.removeField("is_banked");
collection.schema.removeField("manual_override");
collection.schema.removeField("calculated_hours");
return dao.saveCollection(collection);
})