mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
chore: db cleanup
This commit is contained in:
parent
9fa8cf5793
commit
2cc16f5e4c
@ -0,0 +1,56 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("y7qb3zm8vslkfxj");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
}, (db) => {
|
||||
const collection = new Collection({
|
||||
"id": "y7qb3zm8vslkfxj",
|
||||
"created": "2023-09-15 13:56:42.907Z",
|
||||
"updated": "2023-09-27 06:39:53.322Z",
|
||||
"name": "potentialPaidUsersView",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "mkmeisox",
|
||||
"name": "email",
|
||||
"type": "email",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"exceptDomains": null,
|
||||
"onlyDomains": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "wqw6fejd",
|
||||
"name": "secondsthismonth",
|
||||
"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": {
|
||||
"query": "SELECT u.id,\n u.email,\n u.secondsthismonth\nFROM users u\nWHERE u.verified=1 and u.secondsthismonth/60>200"
|
||||
}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
})
|
209
src/mothership-app/migrations/1699186586_deleted_statsView.js
Normal file
209
src/mothership-app/migrations/1699186586_deleted_statsView.js
Normal file
@ -0,0 +1,209 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("se6fljwhhc03k4q");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
}, (db) => {
|
||||
const collection = new Collection({
|
||||
"id": "se6fljwhhc03k4q",
|
||||
"created": "2023-06-23 01:11:55.281Z",
|
||||
"updated": "2023-08-13 14:10:47.344Z",
|
||||
"name": "statsView",
|
||||
"type": "view",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "hwuhhncl",
|
||||
"name": "daysUp",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "4ki5frha",
|
||||
"name": "userCount",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "t0sc7gbx",
|
||||
"name": "runningInstanceCount",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "tdzm0fm9",
|
||||
"name": "instanceCount",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "qgwuokdt",
|
||||
"name": "instanceCount1Hour",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "qdfrdpgw",
|
||||
"name": "instanceCount1Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "7zyst2n4",
|
||||
"name": "instanceCount7Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "spsatpua",
|
||||
"name": "instanceCount30Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "hkqkppxr",
|
||||
"name": "invocationCount",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "p1elamx9",
|
||||
"name": "invocationCount1Hour",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "zx0hsiah",
|
||||
"name": "invocationCount1Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "3umjdlx9",
|
||||
"name": "invocationCount7Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "e6vw9wsl",
|
||||
"name": "invocationCount30Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ms888ft7",
|
||||
"name": "invocationSeconds",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "bv2uips5",
|
||||
"name": "invocationSeconds1Hour",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "zf8r0moy",
|
||||
"name": "invocationSeconds1Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ufpswspy",
|
||||
"name": "invocationSeconds7Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "gd98rnvo",
|
||||
"name": "invocationSeconds30Day",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"query": "select\n (ROW_NUMBER() OVER()) as id, \n (select julianday('now') - julianday( '2023-06-01' )) as daysUp,\n (select count(*) from users where verified=TRUE) as userCount,\n (select count(*) from instances where status='running') as runningInstanceCount,\n (select count(distinct instanceId) from invocations ) as instanceCount,\n (select count(distinct instanceId) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-1 hour'))) as instanceCount1Hour,\n (select count(distinct instanceId) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-1 day'))) as instanceCount1Day,\n (select count(distinct instanceId) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-7 day'))) as instanceCount7Day,\n (select count(distinct instanceId) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-30 day'))) as instanceCount30Day,\n (select count(*) from invocations) as invocationCount,\n (select count(*) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-1 hour'))) as invocationCount1Hour,\n(select count(*) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-1 day'))) as invocationCount1Day,\n(select count(*) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-7 day'))) as invocationCount7Day,\n(select count(*) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-30 day'))) as invocationCount30Day,\n (select sum(totalSeconds) from invocations) as invocationSeconds,\n (select sum(totalSeconds) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-1 hour'))) as invocationSeconds1Hour,\n (select sum(totalSeconds) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-1 day'))) as invocationSeconds1Day,\n (select sum(totalSeconds) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-7 day'))) as invocationSeconds7Day,\n (select sum(totalSeconds) from invocations where created > STRFTIME('%Y-%m-%d %H:%fZ', datetime('now','-30 day'))) as invocationSeconds30Day\n\n\n\n\n\n\n\n\n"
|
||||
}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
})
|
128
src/mothership-app/migrations/1699186600_deleted_invocations.js
Normal file
128
src/mothership-app/migrations/1699186600_deleted_invocations.js
Normal file
@ -0,0 +1,128 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("aiw8te7y7atklwn");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
}, (db) => {
|
||||
const collection = new Collection({
|
||||
"id": "aiw8te7y7atklwn",
|
||||
"created": "2022-11-06 06:05:46.988Z",
|
||||
"updated": "2023-10-02 10:58:44.665Z",
|
||||
"name": "invocations",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "kmyokg1d",
|
||||
"name": "uid",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "systemprofiles0",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "st9ydrbo",
|
||||
"name": "instanceId",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "etae8tuiaxl6xfv",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "av4mpuyh",
|
||||
"name": "startedAt",
|
||||
"type": "date",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": "",
|
||||
"max": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "fnwatixg",
|
||||
"name": "endedAt",
|
||||
"type": "date",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": "",
|
||||
"max": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "awjozhbn",
|
||||
"name": "pid",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "vdkfqege",
|
||||
"name": "totalSeconds",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE INDEX `idx_CTV52b6` ON `invocations` (`created`)",
|
||||
"CREATE INDEX `idx_6rNZeTK` ON `invocations` (`instanceId`)",
|
||||
"CREATE INDEX `idx_LTmqfbC` ON `invocations` (`totalSeconds`)",
|
||||
"CREATE INDEX `idx_7YR9a3g` ON `invocations` (\n `instanceId`,\n `created`\n)",
|
||||
"CREATE INDEX `idx_ntC1d1L` ON `invocations` (\n `totalSeconds`,\n `created`\n)",
|
||||
"CREATE INDEX `idx_vViR75E` ON `invocations` (\n `created`,\n `totalSeconds`\n)",
|
||||
"CREATE INDEX `idx_q9LanEj` ON `invocations` (\n `created`,\n `instanceId`\n)",
|
||||
"CREATE INDEX `idx_ueUQe1N` ON `invocations` (`uid`)",
|
||||
"CREATE INDEX `idx_gh6iEUG` ON `invocations` (\n `instanceId`,\n `startedAt`\n)",
|
||||
"CREATE INDEX `idx_CUsNbfu` ON `invocations` (\n `uid`,\n `startedAt`\n)",
|
||||
"CREATE INDEX `idx_O3bEfl0` ON `invocations` (`updated`)",
|
||||
"CREATE INDEX `idx_qOyDhVG` ON `invocations` (`created`)",
|
||||
"CREATE INDEX `idx_UM6cwSA` ON `invocations` (`instanceId`)",
|
||||
"CREATE INDEX `idx_nMr318s` ON `invocations` (`totalSeconds`)"
|
||||
],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
})
|
@ -0,0 +1,31 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("etae8tuiaxl6xfv")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("1arlklqq")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("etae8tuiaxl6xfv")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "1arlklqq",
|
||||
"name": "secondsThisMonth",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
37
src/mothership-app/migrations/1699186688_updated_users.js
Normal file
37
src/mothership-app/migrations/1699186688_updated_users.js
Normal file
@ -0,0 +1,37 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("systemprofiles0")
|
||||
|
||||
collection.indexes = []
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("qz4cjamg")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("systemprofiles0")
|
||||
|
||||
collection.indexes = [
|
||||
"CREATE INDEX `idx_q4Kji47` ON `users` (`secondsThisMonth`)"
|
||||
]
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "qz4cjamg",
|
||||
"name": "secondsThisMonth",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
@ -0,0 +1,26 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("etae8tuiaxl6xfv")
|
||||
|
||||
collection.indexes = [
|
||||
"CREATE UNIQUE INDEX `idx_unique_qdtuuld1` ON `instances` (`subdomain`)",
|
||||
"CREATE INDEX `idx_DKUSkMx` ON `instances` (`status`)",
|
||||
"CREATE INDEX `idx_fhfKrpl` ON `instances` (`uid`)",
|
||||
"CREATE INDEX `idx_TfdgNnO` ON `instances` (`maintenance`)",
|
||||
"CREATE INDEX `idx_FrmHehp` ON `instances` (`created`)",
|
||||
"CREATE INDEX `idx_tNMeylJ` ON `instances` (`updated`)"
|
||||
]
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("etae8tuiaxl6xfv")
|
||||
|
||||
collection.indexes = [
|
||||
"CREATE UNIQUE INDEX `idx_unique_qdtuuld1` ON `instances` (`subdomain`)",
|
||||
"CREATE INDEX `idx_DKUSkMx` ON `instances` (`status`)"
|
||||
]
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
91
src/mothership-app/migrations/1699543209_deleted_rpc.js
Normal file
91
src/mothership-app/migrations/1699543209_deleted_rpc.js
Normal file
@ -0,0 +1,91 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("v7s41iokt1vizxd");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
}, (db) => {
|
||||
const collection = new Collection({
|
||||
"id": "v7s41iokt1vizxd",
|
||||
"created": "2022-11-15 03:28:33.097Z",
|
||||
"updated": "2023-06-19 02:56:16.446Z",
|
||||
"name": "rpc",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "yv38czcf",
|
||||
"name": "userId",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "systemprofiles0",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "tgvaxwfv",
|
||||
"name": "payload",
|
||||
"type": "json",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "zede8pci",
|
||||
"name": "status",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "nd7cwqmn",
|
||||
"name": "result",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "2hlrcx5j",
|
||||
"name": "cmd",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "userId = @request.auth.id",
|
||||
"viewRule": "userId = @request.auth.id",
|
||||
"createRule": "userId = @request.auth.id && status='' && result=''",
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user