mirror of
https://github.com/pockethost/pockethost.git
synced 2025-05-19 13:26:42 +00:00
chore: track uid in invocations
This commit is contained in:
parent
f0bc038397
commit
791876d0ed
@ -4,6 +4,7 @@ export const INVOCATION_COLLECTION = 'invocations'
|
||||
|
||||
export type InvocationPid = string
|
||||
export type InvocationFields = BaseFields & {
|
||||
uid: RecordId
|
||||
instanceId: RecordId
|
||||
startedAt: IsoDate
|
||||
endedAt: IsoDate
|
||||
|
54
packages/daemon/migrations/1695129360_updated_invocations.js
Normal file
54
packages/daemon/migrations/1695129360_updated_invocations.js
Normal file
@ -0,0 +1,54 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("aiw8te7y7atklwn")
|
||||
|
||||
collection.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`)"
|
||||
]
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"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
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("aiw8te7y7atklwn")
|
||||
|
||||
collection.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)"
|
||||
]
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("kmyokg1d")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
@ -0,0 +1,10 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
migrate(
|
||||
(db) => {
|
||||
db.newQuery(
|
||||
'UPDATE invocations SET uid = (select uid from instances where instances.id = invocations.instanceId)',
|
||||
).execute()
|
||||
},
|
||||
(db) => {},
|
||||
)
|
36
packages/daemon/migrations/1695130842_updated_invocations.js
Normal file
36
packages/daemon/migrations/1695130842_updated_invocations.js
Normal file
@ -0,0 +1,36 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("aiw8te7y7atklwn")
|
||||
|
||||
collection.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)"
|
||||
]
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("aiw8te7y7atklwn")
|
||||
|
||||
collection.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`)"
|
||||
]
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
@ -22,6 +22,7 @@ export const createInvocationMixin = (
|
||||
logger,
|
||||
async (instance: InstanceFields, pid: InvocationPid) => {
|
||||
const init: Partial<InvocationFields> = {
|
||||
uid: instance.uid,
|
||||
startedAt: pocketNow(),
|
||||
pid,
|
||||
instanceId: instance.id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user