mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Added cascade delete for stripe products and prices (#12891)
refs https://github.com/TryGhost/Team/issues/586 If a product inside Ghost is deleted, we want to cascade delete all associated Stripe products and prices as they always need to refer back to a ghost product and will hang without any reason otherwise. This change adds cascade delete for products -> stripe_products -> stripe_prices to avoid broken states
This commit is contained in:
parent
bf0823c9a2
commit
5da4ae90b2
4 changed files with 5 additions and 5 deletions
|
@ -2,7 +2,7 @@ const {addTable} = require('../../utils');
|
||||||
|
|
||||||
module.exports = addTable('stripe_products', {
|
module.exports = addTable('stripe_products', {
|
||||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||||
product_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'products.id'},
|
product_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'products.id', cascadeDelete: true},
|
||||||
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
||||||
created_at: {type: 'dateTime', nullable: false},
|
created_at: {type: 'dateTime', nullable: false},
|
||||||
updated_at: {type: 'dateTime', nullable: true}
|
updated_at: {type: 'dateTime', nullable: true}
|
||||||
|
|
|
@ -3,7 +3,7 @@ const {addTable} = require('../../utils');
|
||||||
module.exports = addTable('stripe_prices', {
|
module.exports = addTable('stripe_prices', {
|
||||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||||
stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
||||||
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id'},
|
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id', cascadeDelete: true},
|
||||||
active: {type: 'boolean', nullable: false},
|
active: {type: 'boolean', nullable: false},
|
||||||
nickname: {type: 'string', maxlength: 50, nullable: true},
|
nickname: {type: 'string', maxlength: 50, nullable: true},
|
||||||
currency: {type: 'string', maxLength: 3, nullable: false},
|
currency: {type: 'string', maxLength: 3, nullable: false},
|
||||||
|
|
|
@ -480,7 +480,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
stripe_products: {
|
stripe_products: {
|
||||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||||
product_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'products.id'},
|
product_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'products.id', cascadeDelete: true},
|
||||||
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
||||||
created_at: {type: 'dateTime', nullable: false},
|
created_at: {type: 'dateTime', nullable: false},
|
||||||
updated_at: {type: 'dateTime', nullable: true}
|
updated_at: {type: 'dateTime', nullable: true}
|
||||||
|
@ -488,7 +488,7 @@ module.exports = {
|
||||||
stripe_prices: {
|
stripe_prices: {
|
||||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||||
stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
||||||
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id'},
|
stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id', cascadeDelete: true},
|
||||||
active: {type: 'boolean', nullable: false},
|
active: {type: 'boolean', nullable: false},
|
||||||
nickname: {type: 'string', maxlength: 50, nullable: true},
|
nickname: {type: 'string', maxlength: 50, nullable: true},
|
||||||
currency: {type: 'string', maxLength: 3, nullable: false},
|
currency: {type: 'string', maxLength: 3, nullable: false},
|
||||||
|
|
|
@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set
|
||||||
*/
|
*/
|
||||||
describe('DB version integrity', function () {
|
describe('DB version integrity', function () {
|
||||||
// Only these variables should need updating
|
// Only these variables should need updating
|
||||||
const currentSchemaHash = '19f3f2750320798dac398be2eb51d3e5';
|
const currentSchemaHash = 'b94aa62d6e50eb42280837605e3f4a66';
|
||||||
const currentFixturesHash = '3dc9747eadecec34958dfba14c5332db';
|
const currentFixturesHash = '3dc9747eadecec34958dfba14c5332db';
|
||||||
const currentSettingsHash = 'b943cc3956eee3dd042f8394b2701d21';
|
const currentSettingsHash = 'b943cc3956eee3dd042f8394b2701d21';
|
||||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||||
|
|
Loading…
Add table
Reference in a new issue