2025-09-12 11:31:06 +00:00
|
|
|
/// <reference path="../pb_data/types.d.ts" />
|
|
|
|
|
|
|
|
|
|
migrate((app) => {
|
|
|
|
|
const collection = new Collection({
|
|
|
|
|
"id": "pbc_suppliers", // Unique ID for the suppliers collection
|
|
|
|
|
"name": "suppliers",
|
|
|
|
|
"type": "base",
|
|
|
|
|
"system": false,
|
|
|
|
|
"listRule": null,
|
|
|
|
|
"viewRule": null,
|
|
|
|
|
"createRule": null,
|
|
|
|
|
"updateRule": null,
|
|
|
|
|
"deleteRule": null,
|
|
|
|
|
"schema": [
|
|
|
|
|
{
|
|
|
|
|
"autogeneratePattern": "[a-z0-9]{15}",
|
2025-09-12 11:37:56 +00:00
|
|
|
"hidden": false,
|
|
|
|
|
"id": "text3208210256",
|
2025-09-12 11:31:06 +00:00
|
|
|
"max": 15,
|
|
|
|
|
"min": 15,
|
2025-09-12 11:37:56 +00:00
|
|
|
"name": "id",
|
2025-09-12 11:31:06 +00:00
|
|
|
"pattern": "^[a-z0-9]+$",
|
|
|
|
|
"presentable": false,
|
2025-09-12 11:37:56 +00:00
|
|
|
"primaryKey": true,
|
|
|
|
|
"required": true,
|
|
|
|
|
"system": true,
|
|
|
|
|
"type": "text"
|
2025-09-12 11:31:06 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"autogeneratePattern": "",
|
2025-09-12 11:37:56 +00:00
|
|
|
"hidden": false,
|
|
|
|
|
"id": "text2474346735",
|
2025-09-12 11:31:06 +00:00
|
|
|
"max": 0,
|
|
|
|
|
"min": 0,
|
2025-09-12 11:37:56 +00:00
|
|
|
"name": "supplier_name", // Corrected from 'supplier_name' to 'supplier_name'
|
2025-09-12 11:31:06 +00:00
|
|
|
"pattern": "",
|
2025-09-12 11:37:56 +00:00
|
|
|
"presentable": false,
|
|
|
|
|
"primaryKey": false,
|
|
|
|
|
"required": false,
|
|
|
|
|
"system": false,
|
|
|
|
|
"type": "text"
|
2025-09-12 11:31:06 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"autogeneratePattern": "",
|
2025-09-12 11:37:56 +00:00
|
|
|
"hidden": false,
|
|
|
|
|
"id": "text4003876389",
|
2025-09-12 11:31:06 +00:00
|
|
|
"max": 0,
|
|
|
|
|
"min": 0,
|
2025-09-12 11:37:56 +00:00
|
|
|
"name": "supplier_address", // Corrected typo from 'suppier_address'
|
2025-09-12 11:31:06 +00:00
|
|
|
"pattern": "",
|
2025-09-12 11:37:56 +00:00
|
|
|
"presentable": false,
|
|
|
|
|
"primaryKey": false,
|
|
|
|
|
"required": false,
|
|
|
|
|
"system": false,
|
|
|
|
|
"type": "text"
|
2025-09-12 11:31:06 +00:00
|
|
|
},
|
|
|
|
|
{
|
2025-09-12 11:37:56 +00:00
|
|
|
"exceptDomains": null,
|
|
|
|
|
"hidden": false,
|
|
|
|
|
"id": "email1049198174",
|
|
|
|
|
"name": "supplier_email",
|
|
|
|
|
"onlyDomains": null,
|
2025-09-12 11:31:06 +00:00
|
|
|
"presentable": false,
|
2025-09-12 11:37:56 +00:00
|
|
|
"required": false,
|
|
|
|
|
"system": false,
|
|
|
|
|
"type": "email"
|
2025-09-12 11:31:06 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"autogeneratePattern": "",
|
2025-09-12 11:37:56 +00:00
|
|
|
"hidden": false,
|
|
|
|
|
"id": "text23603970",
|
2025-09-12 11:31:06 +00:00
|
|
|
"max": 0,
|
|
|
|
|
"min": 0,
|
2025-09-12 11:37:56 +00:00
|
|
|
"name": "supplier_phone_number", // Corrected from 'supplier_phone'
|
2025-09-12 11:31:06 +00:00
|
|
|
"pattern": "",
|
2025-09-12 11:37:56 +00:00
|
|
|
"presentable": false,
|
|
|
|
|
"primaryKey": false,
|
|
|
|
|
"required": false,
|
|
|
|
|
"system": false,
|
|
|
|
|
"type": "text"
|
2025-09-12 11:31:06 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"id": "supplier_created", // Unique ID for the 'created' field
|
|
|
|
|
"name": "created",
|
|
|
|
|
"type": "autodate",
|
|
|
|
|
"system": true,
|
|
|
|
|
"required": false,
|
|
|
|
|
"onCreate": true,
|
|
|
|
|
"onUpdate": false,
|
|
|
|
|
"presentable": false,
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"id": "supplier_updated", // Unique ID for the 'updated' field
|
|
|
|
|
"name": "updated",
|
|
|
|
|
"type": "autodate",
|
|
|
|
|
"system": true,
|
|
|
|
|
"required": false,
|
|
|
|
|
"onCreate": true,
|
|
|
|
|
"onUpdate": true,
|
|
|
|
|
"presentable": false,
|
|
|
|
|
"hidden": false
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"indexes": [],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return app.save(collection);
|
|
|
|
|
}, (app) => {
|
|
|
|
|
const collection = app.findCollectionByNameOrId("pbc_suppliers");
|
2025-09-12 11:37:56 +00:00
|
|
|
// Revert changes if necessary, though typically migrations are forward-only.
|
|
|
|
|
// For simplicity, we'll just delete the collection on downgrade.
|
2025-09-12 11:31:06 +00:00
|
|
|
return app.delete(collection);
|
|
|
|
|
});
|