feat: create database schema

This commit is contained in:
HerozDotExe 2025-08-04 15:34:42 +02:00
parent 6755d5eec6
commit ed94a8de34
5 changed files with 409 additions and 0 deletions

View file

@ -0,0 +1,101 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((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": "text107555668",
"max": 15,
"min": 5,
"name": "access",
"pattern": "^[[:alnum:]]+$",
"presentable": true,
"primaryKey": false,
"required": true,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1579384326",
"max": 20,
"min": 5,
"name": "name",
"pattern": "",
"presentable": true,
"primaryKey": false,
"required": true,
"system": false,
"type": "text"
},
{
"cascadeDelete": true,
"collectionId": "_pb_users_auth_",
"hidden": false,
"id": "relation3479234172",
"maxSelect": 1,
"minSelect": 0,
"name": "owner",
"presentable": true,
"required": true,
"system": false,
"type": "relation"
},
{
"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_506322039",
"indexes": [
"CREATE UNIQUE INDEX `idx_ga9IDWWYbf` ON `subheddit` (`access`)",
"CREATE UNIQUE INDEX `idx_92fMLQnrtL` ON `subheddit` (`name`)"
],
"listRule": null,
"name": "subheddit",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
});
return app.save(collection);
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_506322039");
return app.delete(collection);
})

View file

@ -0,0 +1,112 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((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"
},
{
"cascadeDelete": false,
"collectionId": "pbc_506322039",
"hidden": false,
"id": "relation2047228655",
"maxSelect": 1,
"minSelect": 0,
"name": "subheddit",
"presentable": false,
"required": false,
"system": false,
"type": "relation"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text107555668",
"max": 15,
"min": 5,
"name": "access",
"pattern": "^[[:alnum:]]+$",
"presentable": true,
"primaryKey": false,
"required": true,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text724990059",
"max": 30,
"min": 5,
"name": "title",
"pattern": "",
"presentable": true,
"primaryKey": false,
"required": true,
"system": false,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text4274335913",
"max": 1000,
"min": 5,
"name": "content",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": true,
"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_1125843985",
"indexes": [],
"listRule": null,
"name": "posts",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
});
return app.save(collection);
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1125843985");
return app.delete(collection);
})

View file

@ -0,0 +1,71 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1125843985")
// update collection data
unmarshal({
"indexes": [
"CREATE INDEX `idx_MDeVB5Slv3` ON `posts` (`access`)",
"CREATE INDEX `idx_GIZ2HcAMVx` ON `posts` (`title`)"
]
}, collection)
// add field
collection.fields.addAt(1, new Field({
"cascadeDelete": false,
"collectionId": "_pb_users_auth_",
"hidden": false,
"id": "relation3182418120",
"maxSelect": 1,
"minSelect": 0,
"name": "author",
"presentable": true,
"required": true,
"system": false,
"type": "relation"
}))
// update field
collection.fields.addAt(2, new Field({
"cascadeDelete": false,
"collectionId": "pbc_506322039",
"hidden": false,
"id": "relation2047228655",
"maxSelect": 1,
"minSelect": 0,
"name": "subheddit",
"presentable": true,
"required": true,
"system": false,
"type": "relation"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1125843985")
// update collection data
unmarshal({
"indexes": []
}, collection)
// remove field
collection.fields.removeById("relation3182418120")
// update field
collection.fields.addAt(1, new Field({
"cascadeDelete": false,
"collectionId": "pbc_506322039",
"hidden": false,
"id": "relation2047228655",
"maxSelect": 1,
"minSelect": 0,
"name": "subheddit",
"presentable": false,
"required": false,
"system": false,
"type": "relation"
}))
return app.save(collection)
})

View file

@ -0,0 +1,97 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((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"
},
{
"cascadeDelete": false,
"collectionId": "_pb_users_auth_",
"hidden": false,
"id": "relation3182418120",
"maxSelect": 1,
"minSelect": 0,
"name": "author",
"presentable": true,
"required": true,
"system": false,
"type": "relation"
},
{
"cascadeDelete": false,
"collectionId": "pbc_1125843985",
"hidden": false,
"id": "relation2287844090",
"maxSelect": 1,
"minSelect": 0,
"name": "posts",
"presentable": true,
"required": true,
"system": false,
"type": "relation"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text4274335913",
"max": 200,
"min": 5,
"name": "content",
"pattern": "",
"presentable": true,
"primaryKey": false,
"required": true,
"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_533777971",
"indexes": [],
"listRule": null,
"name": "comments",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
});
return app.save(collection);
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_533777971");
return app.delete(collection);
})

View file

@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_506322039")
// update collection data
unmarshal({
"indexes": [
"CREATE UNIQUE INDEX `idx_ga9IDWWYbf` ON `subheddits` (`access`)",
"CREATE UNIQUE INDEX `idx_92fMLQnrtL` ON `subheddits` (`name`)"
],
"name": "subheddits"
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_506322039")
// update collection data
unmarshal({
"indexes": [
"CREATE UNIQUE INDEX `idx_ga9IDWWYbf` ON `subheddit` (`access`)",
"CREATE UNIQUE INDEX `idx_92fMLQnrtL` ON `subheddit` (`name`)"
],
"name": "subheddit"
}, collection)
return app.save(collection)
})