Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ghost/core/core/server/data/exporter/table-lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const BACKUP_TABLES = [
'actions',
'api_keys',
'automated_email_recipients',
'automated_emails',
'brute',
'donation_payment_events',
'email_design_settings',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const logging = require('@tryghost/logging');
const {commands} = require('../../../schema');
const {createNonTransactionalMigration} = require('../../utils');

const oldAutomatedEmailsSpec = {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'inactive', validations: {isIn: [['active', 'inactive']]}},
name: {type: 'string', maxlength: 191, nullable: false, unique: true},
slug: {type: 'string', maxlength: 191, nullable: false, unique: true},
subject: {type: 'string', maxlength: 300, nullable: false},
lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
sender_name: {type: 'string', maxlength: 191, nullable: true},
sender_email: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}},
sender_reply_to: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}},
email_design_setting_id: {type: 'string', maxlength: 24, nullable: false, references: 'email_design_settings.id'},
created_at: {type: 'dateTime', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
'@@INDEXES@@': [
['slug'],
['status']
]
};

module.exports = createNonTransactionalMigration(
async function up(knex) {
const exists = await knex.schema.hasTable('automated_emails');
if (!exists) {
logging.warn('Skipping dropping table automated_emails - does not exist');
return;
}

logging.info('Dropping table: automated_emails');
await commands.deleteTable('automated_emails', knex);
},

async function down(knex) {
const exists = await knex.schema.hasTable('automated_emails');
if (exists) {
logging.warn('Skipping recreating table automated_emails - already exists');
return;
}

logging.info('Recreating table: automated_emails');
await commands.createTable('automated_emails', knex, oldAutomatedEmailsSpec);
}
);
18 changes: 0 additions & 18 deletions ghost/core/core/server/data/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,24 +1189,6 @@ module.exports = {
created_at: {type: 'dateTime', nullable: false},
updated_at: {type: 'dateTime', nullable: true}
},
automated_emails: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'inactive', validations: {isIn: [['active', 'inactive']]}},
name: {type: 'string', maxlength: 191, nullable: false, unique: true},
slug: {type: 'string', maxlength: 191, nullable: false, unique: true},
subject: {type: 'string', maxlength: 300, nullable: false},
lexical: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
sender_name: {type: 'string', maxlength: 191, nullable: true},
sender_email: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}},
sender_reply_to: {type: 'string', maxlength: 191, nullable: true, validations: {isEmail: true}},
email_design_setting_id: {type: 'string', maxlength: 24, nullable: false, references: 'email_design_settings.id'},
created_at: {type: 'dateTime', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
'@@INDEXES@@': [
['slug'],
['status']
]
},
automated_email_recipients: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
automated_email_id: {type: 'string', maxlength: 24, nullable: false, references: 'welcome_email_automated_emails.id'},
Expand Down
1 change: 0 additions & 1 deletion ghost/core/test/integration/exporter/exporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('Exporter', function () {
'actions',
'api_keys',
'automated_email_recipients',
'automated_emails',
'benefits',
'brute',
'collections',
Expand Down
2 changes: 1 addition & 1 deletion ghost/core/test/unit/server/data/schema/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = 'f57e57fd042ecee9dd93410ae87c0454';
const currentSchemaHash = '6186d5aa5b62b6689ee8786efd5daccc';
const currentFixturesHash = '2f86ab1e3820e86465f9ad738dd0ee93';
const currentSettingsHash = 'a102b80d2ab0cd92325ed007c94d7da6';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
Expand Down
Loading