mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
🐛 Fixed a foreign key to point to the right column
pr https://github.com/TryGhost/Ghost/pull/12713
This commit is contained in:
parent
6a512a50f9
commit
2eb5f19090
@ -61,14 +61,14 @@ module.exports = createIrreversibleMigration(async (knex) => {
|
||||
fromTable: 'members_stripe_customers_subscriptions',
|
||||
fromColumn: 'customer_id',
|
||||
toTable: 'members_stripe_customers',
|
||||
toColumn: 'id',
|
||||
toColumn: 'customer_id',
|
||||
transaction: knex
|
||||
});
|
||||
await addForeign({
|
||||
fromTable: 'members_stripe_customers_subscriptions',
|
||||
fromColumn: 'customer_id',
|
||||
toTable: 'members_stripe_customers',
|
||||
toColumn: 'id',
|
||||
toColumn: 'customer_id',
|
||||
cascadeDelete: true,
|
||||
transaction: knex
|
||||
});
|
||||
|
@ -0,0 +1,34 @@
|
||||
const logging = require('../../../../../shared/logging');
|
||||
const {createIrreversibleMigration} = require('../../utils');
|
||||
const {addForeign, dropForeign} = require('../../../schema/commands');
|
||||
|
||||
module.exports = createIrreversibleMigration(async (knex) => {
|
||||
if (knex.client.config.client !== 'sqlite3') {
|
||||
return logging.warn('Skipping fixing foreign key for members_stripe_customers_subscriptions - database is not SQLite3');
|
||||
}
|
||||
|
||||
logging.info('Fixing foreign keys for members_stripe_customers_subscriptions');
|
||||
|
||||
await dropForeign({
|
||||
fromTable: 'members_stripe_customers_subscriptions',
|
||||
fromColumn: 'customer_id',
|
||||
toTable: 'members_stripe_customers',
|
||||
toColumn: 'id',
|
||||
transaction: knex
|
||||
});
|
||||
await dropForeign({
|
||||
fromTable: 'members_stripe_customers_subscriptions',
|
||||
fromColumn: 'customer_id',
|
||||
toTable: 'members_stripe_customers',
|
||||
toColumn: 'customer_id',
|
||||
transaction: knex
|
||||
});
|
||||
await addForeign({
|
||||
fromTable: 'members_stripe_customers_subscriptions',
|
||||
fromColumn: 'customer_id',
|
||||
toTable: 'members_stripe_customers',
|
||||
toColumn: 'customer_id',
|
||||
cascadeDelete: true,
|
||||
transaction: knex
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user