27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
|
|
/**
|
|
* projects/documents came out of migration 1 with no created/updated
|
|
* fields at all - confirmed for real (not assumed): documentsService's
|
|
* own `sort: '-created'` failed with a generic 400 against the live
|
|
* collection, traced down to the field simply not existing (the `users`
|
|
* auth collection has one built in; a plain base collection doesn't
|
|
* unless declared explicitly). Field syntax below copied from `users`'
|
|
* own `created`/`updated` fields via the REST API, not guessed.
|
|
*/
|
|
migrate((app) => {
|
|
for (const name of ['projects', 'documents']) {
|
|
let collection = app.findCollectionByNameOrId(name)
|
|
collection.fields.add(new Field({ type: 'autodate', name: 'created', onCreate: true, onUpdate: false }))
|
|
collection.fields.add(new Field({ type: 'autodate', name: 'updated', onCreate: true, onUpdate: true }))
|
|
app.save(collection)
|
|
}
|
|
}, (app) => {
|
|
for (const name of ['projects', 'documents']) {
|
|
let collection = app.findCollectionByNameOrId(name)
|
|
collection.fields.removeByName('created')
|
|
collection.fields.removeByName('updated')
|
|
app.save(collection)
|
|
}
|
|
})
|