refactor: update database schema and migration files

This commit is contained in:
Tola Leng
2025-10-11 20:45:10 +07:00
parent ee5e66eb44
commit 7392580db8
17 changed files with 833 additions and 66 deletions
@@ -0,0 +1,29 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_3142635823")
// add field
collection.fields.addAt(9, new Field({
"hidden": false,
"id": "file376926767",
"maxSelect": 1,
"maxSize": 0,
"mimeTypes": [],
"name": "avatar",
"presentable": false,
"protected": false,
"required": false,
"system": false,
"thumbs": [],
"type": "file"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_3142635823")
// remove field
collection.fields.removeById("file376926767")
return app.save(collection)
})
@@ -0,0 +1,78 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1938176441")
// add field
collection.fields.addAt(23, new Field({
"autogeneratePattern": "",
"hidden": false,
"id": "text3401535476",
"max": 0,
"min": 0,
"name": "server_url",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}))
// update field
collection.fields.addAt(9, new Field({
"hidden": false,
"id": "select887233555",
"maxSelect": 1,
"name": "notification_type",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"telegram",
"signal",
"discord",
"slack",
"webhook",
"google_chat",
"email",
"ntfy",
"pushover",
"notifiarr",
"gotify"
]
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1938176441")
// remove field
collection.fields.removeById("text3401535476")
// update field
collection.fields.addAt(9, new Field({
"hidden": false,
"id": "select887233555",
"maxSelect": 1,
"name": "notification_type",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"telegram",
"signal",
"discord",
"slack",
"webhook",
"google_chat",
"email",
"ntfy",
"pushover",
"notifiarr"
]
}))
return app.save(collection)
})
@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2889059272")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"listRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\"",
"viewRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2889059272")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,26 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2189087560")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"listRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2189087560")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": ""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,24 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1738231158")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1738231158")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"updateRule": ""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,20 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2189087560")
// update collection data
unmarshal({
"listRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2189087560")
// update collection data
unmarshal({
"listRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,24 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_3662317132")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_3662317132")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"updateRule": ""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,20 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1168766540")
// update collection data
unmarshal({
"deleteRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1168766540")
// update collection data
unmarshal({
"deleteRule": ""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1938176441")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"listRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\"",
"viewRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1938176441")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1938176441")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1938176441")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"listRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\"",
"viewRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,211 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_45665081");
return app.delete(collection);
}, (app) => {
const collection = new Collection({
"createRule": null,
"deleteRule": null,
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text3208210256",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text2809058197",
"max": 0,
"min": 0,
"name": "user_id",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text4101391790",
"max": 0,
"min": 0,
"name": "url",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"hidden": false,
"id": "select1358543748",
"maxSelect": 1,
"name": "enabled",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"on",
"off"
]
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1554180325",
"max": 0,
"min": 0,
"name": "secret",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text4144189317",
"max": 0,
"min": 0,
"name": "headers",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text2129530235",
"max": 0,
"min": 0,
"name": "retry_count",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text2168550802",
"max": 0,
"min": 0,
"name": "trigger_events",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1843675174",
"max": 0,
"min": 0,
"name": "description",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1579384326",
"max": 0,
"min": 0,
"name": "name",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1582905952",
"max": 0,
"min": 0,
"name": "method",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1414600993",
"max": 0,
"min": 0,
"name": "payload_template",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"hidden": false,
"id": "autodate2990389176",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate3332085495",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}
],
"id": "pbc_45665081",
"indexes": [],
"listRule": null,
"name": "webhook",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
});
return app.save(collection);
})
@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2889059272")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2889059272")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"listRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\"",
"viewRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,24 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2189087560")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"updateRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2189087560")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,24 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1738231158")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"updateRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1738231158")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,24 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_3662317132")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"updateRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_3662317132")
// update collection data
unmarshal({
"createRule": "@request.auth.id != \"\"",
"deleteRule": "@request.auth.id != \"\"",
"updateRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
@@ -0,0 +1,20 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1168766540")
// update collection data
unmarshal({
"deleteRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1168766540")
// update collection data
unmarshal({
"deleteRule": "@request.auth.id != \"\""
}, collection)
return app.save(collection)
})
+197 -66
View File
@@ -217,7 +217,7 @@
"id": "_pb_users_auth_", "id": "_pb_users_auth_",
"listRule": "id = @request.auth.id", "listRule": "id = @request.auth.id",
"viewRule": "id = @request.auth.id", "viewRule": "id = @request.auth.id",
"createRule": null, "createRule": "",
"updateRule": "id = @request.auth.id", "updateRule": "id = @request.auth.id",
"deleteRule": "id = @request.auth.id", "deleteRule": "id = @request.auth.id",
"name": "users", "name": "users",
@@ -271,7 +271,7 @@
"name": "email", "name": "email",
"onlyDomains": null, "onlyDomains": null,
"presentable": false, "presentable": false,
"required": false, "required": true,
"system": true, "system": true,
"type": "email" "type": "email"
}, },
@@ -341,20 +341,6 @@
"system": false, "system": false,
"type": "text" "type": "text"
}, },
{
"hidden": false,
"id": "select2063623452",
"maxSelect": 1,
"name": "status",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"Active",
"Inactive"
]
},
{ {
"hidden": false, "hidden": false,
"id": "autodate2990389176", "id": "autodate2990389176",
@@ -996,7 +982,9 @@
"webhook", "webhook",
"google_chat", "google_chat",
"email", "email",
"ntfy" "ntfy",
"pushover",
"notifiarr"
] ]
}, },
{ {
@@ -1153,6 +1141,34 @@
"system": false, "system": false,
"type": "text" "type": "text"
}, },
{
"autogeneratePattern": "",
"hidden": false,
"id": "text2074277355",
"max": 0,
"min": 0,
"name": "api_token",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1636223522",
"max": 0,
"min": 0,
"name": "user_key",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{ {
"hidden": false, "hidden": false,
"id": "autodate2990389176", "id": "autodate2990389176",
@@ -5638,6 +5654,169 @@
"indexes": [], "indexes": [],
"system": false "system": false
}, },
{
"id": "pbc_1753185970",
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": "",
"name": "ssl_history",
"type": "base",
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text3208210256",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text2812878347",
"max": 0,
"min": 0,
"name": "cert_id",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1881225410",
"max": 0,
"min": 0,
"name": "days_before_expiry",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text3062427817",
"max": 0,
"min": 0,
"name": "days_before_warning",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text98176952",
"max": 0,
"min": 0,
"name": "template_id",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text4011498884",
"max": 0,
"min": 0,
"name": "notification_id",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"hidden": false,
"id": "select3839288252",
"maxSelect": 1,
"name": "warning_status",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"sent",
"pending",
"failed"
]
},
{
"hidden": false,
"id": "select2670434693",
"maxSelect": 1,
"name": "expiry_status",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"sent",
"pending",
"failed"
]
},
{
"hidden": false,
"id": "select3824245652",
"maxSelect": 1,
"name": "critical_status",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"sent",
"pending",
"failed"
]
},
{
"hidden": false,
"id": "autodate2990389176",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate3332085495",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}
],
"indexes": [],
"system": false
},
{ {
"id": "pbc_351174173", "id": "pbc_351174173",
"listRule": "", "listRule": "",
@@ -6083,54 +6262,6 @@
"indexes": [], "indexes": [],
"system": false "system": false
}, },
{
"id": "pbc_4014804571",
"listRule": null,
"viewRule": null,
"createRule": null,
"updateRule": null,
"deleteRule": null,
"name": "trigger_events",
"type": "base",
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text3208210256",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"hidden": false,
"id": "autodate2990389176",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate3332085495",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}
],
"indexes": [],
"system": false
},
{ {
"id": "pbc_67962705", "id": "pbc_67962705",
"listRule": "", "listRule": "",
@@ -6544,4 +6675,4 @@
"indexes": [], "indexes": [],
"system": false "system": false
} }
] ]