mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Fixed Action event resource_type
from page
to post
refs https://github.com/TryGhost/Toolbox/issues/356
refs 3a9016639c
- I misunderstood the purpose of a column, and changed the values that
are inserted into it, which broke relation includes in Bookshelf
- I've since reverted that in the commit above but this migration is to
fixup the data that got stored in the DB
- we want to replace `resource_type` = `page` back to `post`, but then
use the `context` column as described in the referenced commit to
store that the type is actually a `page`, so we can link to it
from the audit log accordingly
- I'm overwriting the `context` column without taking into account the
current contents but that's ok because this bug existed before we
started using `context`
This commit is contained in:
parent
04161d2f7d
commit
5e38a23976
1 changed files with 22 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
const logging = require('@tryghost/logging');
|
||||
const {createTransactionalMigration} = require('../../utils');
|
||||
|
||||
module.exports = createTransactionalMigration(
|
||||
async function up(knex) {
|
||||
logging.info(`Changing Action event 'page' resource_type to 'post'`);
|
||||
|
||||
const affectedRows = await knex('actions')
|
||||
.update({
|
||||
resource_type: 'post',
|
||||
context: JSON.stringify({
|
||||
type: 'page'
|
||||
})
|
||||
})
|
||||
.where('resource_type', 'page');
|
||||
|
||||
logging.info(`Updated ${affectedRows} Action events from 'page' to 'post'`);
|
||||
},
|
||||
async function down() {
|
||||
// no-op: we don't want to put `pages` back as a resource type
|
||||
}
|
||||
);
|
Loading…
Add table
Reference in a new issue