39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
//
|
|
// M19 — Add customerId to appointments collection.
|
|
|
|
migrate(
|
|
function (db) {
|
|
var col = null;
|
|
try { col = db.findCollectionByNameOrId('appointments'); } catch (e) {}
|
|
if (!col) {
|
|
console.warn('[M19] appointments collection not found — skipping');
|
|
return;
|
|
}
|
|
|
|
for (var i = 0; i < col.fields.length; i++) {
|
|
if (col.fields[i].name === 'customerId') {
|
|
console.log('[M19] customerId already exists — skipping');
|
|
return;
|
|
}
|
|
}
|
|
|
|
col.fields.push(new TextField({ name: 'customerId', required: false }));
|
|
db.save(col);
|
|
console.log('[M19] added customerId to appointments');
|
|
},
|
|
function (db) {
|
|
var col = null;
|
|
try { col = db.findCollectionByNameOrId('appointments'); } catch (e) {}
|
|
if (!col) return;
|
|
for (var i = 0; i < col.fields.length; i++) {
|
|
if (col.fields[i].name === 'customerId') {
|
|
col.fields.splice(i, 1);
|
|
db.save(col);
|
|
console.log('[M19] removed customerId from appointments');
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
);
|