Add pocketbase migrations

This commit is contained in:
Niklas Korz 2023-12-08 21:34:16 +01:00
parent c75003f5f0
commit 0d330c4f60
13 changed files with 547 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/pocketbase
/pb_data/

View file

@ -0,0 +1,82 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const collection = new Collection({
"id": "pf13z4hs1iubw41",
"created": "2023-12-08 18:40:59.946Z",
"updated": "2023-12-08 18:40:59.946Z",
"name": "tasks",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "hthpvzja",
"name": "name",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "hrzb5spy",
"name": "description",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "qjz9b0tm",
"name": "schedule",
"type": "date",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": "",
"max": ""
}
},
{
"system": false,
"id": "ryukqaol",
"name": "repeatInterval",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}
],
"indexes": [],
"listRule": null,
"viewRule": null,
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {}
});
return Dao(db).saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41");
return dao.deleteCollection(collection);
})

View file

@ -0,0 +1,41 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const collection = new Collection({
"id": "i42xt9r6ykqdq3j",
"created": "2023-12-08 18:41:27.908Z",
"updated": "2023-12-08 18:41:27.908Z",
"name": "tasklists",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "gjhxaxm4",
"name": "name",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}
],
"indexes": [],
"listRule": null,
"viewRule": null,
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {}
});
return Dao(db).saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j");
return dao.deleteCollection(collection);
})

View file

@ -0,0 +1,48 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// remove
collection.schema.removeField("hrzb5spy")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "bkjgp8xt",
"name": "description",
"type": "editor",
"required": false,
"presentable": false,
"unique": false,
"options": {
"convertUrls": false
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "hrzb5spy",
"name": "description",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}))
// remove
collection.schema.removeField("bkjgp8xt")
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,33 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "6gfllcfj",
"name": "list",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// remove
collection.schema.removeField("6gfllcfj")
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,48 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "6gfllcfj",
"name": "list",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "6gfllcfj",
"name": "list",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,33 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "vm4xdjfy",
"name": "parentList",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j")
// remove
collection.schema.removeField("vm4xdjfy")
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,48 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "6gfllcfj",
"name": "list",
"type": "relation",
"required": true,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "6gfllcfj",
"name": "list",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,44 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "ryukqaol",
"name": "cooldown",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "ryukqaol",
"name": "repeatInterval",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,44 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "ryukqaol",
"name": "cooldown",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": 1,
"max": null,
"noDecimal": true
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("pf13z4hs1iubw41")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "ryukqaol",
"name": "cooldown",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,59 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const collection = new Collection({
"id": "jebj4y3fqo5gtte",
"created": "2023-12-08 19:02:25.763Z",
"updated": "2023-12-08 19:02:25.763Z",
"name": "completions",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "dcsjlzex",
"name": "task",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "pf13z4hs1iubw41",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
},
{
"system": false,
"id": "ewnc7huz",
"name": "user",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "_pb_users_auth_",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}
],
"indexes": [],
"listRule": null,
"viewRule": null,
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {}
});
return Dao(db).saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("jebj4y3fqo5gtte");
return dao.deleteCollection(collection);
})

View file

@ -0,0 +1,16 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j")
collection.name = "lists"
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j")
collection.name = "tasklists"
return dao.saveCollection(collection)
})

View file

@ -0,0 +1,48 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "vm4xdjfy",
"name": "parent",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("i42xt9r6ykqdq3j")
// update
collection.schema.addField(new SchemaField({
"system": false,
"id": "vm4xdjfy",
"name": "parentList",
"type": "relation",
"required": false,
"presentable": false,
"unique": false,
"options": {
"collectionId": "i42xt9r6ykqdq3j",
"cascadeDelete": true,
"minSelect": null,
"maxSelect": 1,
"displayFields": null
}
}))
return dao.saveCollection(collection)
})