mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Revert "Updated plan_nickname column to be nullable"
This reverts commit 5d122c3c62
.
This commit is contained in:
parent
27b9e4ae04
commit
87471fd5c6
3 changed files with 2 additions and 66 deletions
|
@ -1,64 +0,0 @@
|
|||
const {createNonTransactionalMigration} = require('../../utils');
|
||||
const {createTable, deleteTable} = require('../../../schema/commands');
|
||||
const logging = require('../../../../../shared/logging');
|
||||
|
||||
const tableDef = {
|
||||
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||
customer_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'members_stripe_customers.customer_id', cascadeDelete: true},
|
||||
subscription_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
|
||||
plan_id: {type: 'string', maxlength: 255, nullable: false, unique: false},
|
||||
status: {type: 'string', maxlength: 50, nullable: false},
|
||||
cancel_at_period_end: {type: 'bool', nullable: false, defaultTo: false},
|
||||
cancellation_reason: {type: 'string', maxlength: 500, nullable: true},
|
||||
current_period_end: {type: 'dateTime', nullable: false},
|
||||
start_date: {type: 'dateTime', nullable: false},
|
||||
default_payment_card_last4: {type: 'string', maxlength: 4, nullable: true},
|
||||
created_at: {type: 'dateTime', nullable: false},
|
||||
created_by: {type: 'string', maxlength: 24, nullable: false},
|
||||
updated_at: {type: 'dateTime', nullable: true},
|
||||
updated_by: {type: 'string', maxlength: 24, nullable: true},
|
||||
plan_nickname: {type: 'string', maxlength: 50, nullable: true},
|
||||
plan_interval: {type: 'string', maxlength: 50, nullable: false},
|
||||
plan_amount: {type: 'integer', nullable: false},
|
||||
plan_currency: {type: 'string', maxLength: 3, nullable: false}
|
||||
};
|
||||
|
||||
module.exports = createNonTransactionalMigration(
|
||||
async function up(knex) {
|
||||
if (knex.client.config.client === 'mysql') {
|
||||
logging.info('Removing NOT_NULL constraint from members_stripe_customers_subscriptions:plan_nickname');
|
||||
await knex.schema.alterTable('members_stripe_customers_subscriptions', (table) => {
|
||||
table.string('plan_nickname').nullable().alter();
|
||||
});
|
||||
} else {
|
||||
// SQLite3 doesn't support altering columns, so we have to do a wee dance with a temp table.
|
||||
logging.info('Creating temporary table temp_members_stripe_customers_subscriptions');
|
||||
|
||||
await createTable('temp_members_stripe_customers_subscriptions', knex, tableDef);
|
||||
|
||||
logging.info('Copying data to temporary table temp_members_stripe_customers_subscriptions');
|
||||
await knex.raw(`
|
||||
INSERT INTO temp_members_stripe_customers_subscriptions
|
||||
SELECT * FROM members_stripe_customers_subscriptions
|
||||
`);
|
||||
|
||||
logging.info('Dropping table members_stripe_customers_subscriptions');
|
||||
await deleteTable('members_stripe_customers_subscriptions', knex);
|
||||
|
||||
logging.info('Creating table members_stripe_customers_subscriptions');
|
||||
await createTable('members_stripe_customers_subscriptions', knex, tableDef);
|
||||
|
||||
logging.info('Copying data from temporary table to members_stripe_customers_subscriptions');
|
||||
await knex.raw(`
|
||||
INSERT INTO members_stripe_customers_subscriptions
|
||||
SELECT * FROM temp_members_stripe_customers_subscriptions
|
||||
`);
|
||||
|
||||
logging.info('Dropping temporary table temp_members_stripe_customers_subscriptions');
|
||||
await deleteTable('temp_members_stripe_customers_subscriptions', knex);
|
||||
}
|
||||
},
|
||||
async function down() {
|
||||
// noop - we can't add a not null constraint after some of the columns have been nulled
|
||||
}
|
||||
);
|
|
@ -447,7 +447,7 @@ module.exports = {
|
|||
updated_at: {type: 'dateTime', nullable: true},
|
||||
updated_by: {type: 'string', maxlength: 24, nullable: true},
|
||||
/* Below fields eventually should be normalised e.g. stripe_plans table, link to here on plan_id */
|
||||
plan_nickname: {type: 'string', maxlength: 50, nullable: true},
|
||||
plan_nickname: {type: 'string', maxlength: 50, nullable: false},
|
||||
plan_interval: {type: 'string', maxlength: 50, nullable: false},
|
||||
plan_amount: {type: 'integer', nullable: false},
|
||||
plan_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 () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = 'd23279e16028161ab337000744480111';
|
||||
const currentSchemaHash = '5861ed57418a0195ea01e431b8b55335';
|
||||
const currentFixturesHash = '370d0da0ab7c45050b2ff30bce8896ba';
|
||||
const currentSettingsHash = '24453dc02be9df7284acf1748862a545';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
|
Loading…
Add table
Reference in a new issue