0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Migrated email filter columns from VARCHAR to TEXT (#14091)

refs https://github.com/TryGhost/Team/issues/1287

Currently we have a hard limit of how large an email filter can be,
which is very restrictive once a site starts using Tiers - by moving
toward a TEXT column, we essentially give the filters unlimited size.

This currently doesn't handle SQLite as there are no limits on VARCHARS
in SQLite.

The down migration is a loop so we don't have to handle values larger than
50 characters
This commit is contained in:
Fabien 'egg' O'Carroll 2022-02-04 16:09:35 +02:00 committed by GitHub
parent d14757ec07
commit d60d24e744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 5 deletions

View file

@ -0,0 +1,18 @@
const logging = require('@tryghost/logging');
const {createNonTransactionalMigration} = require('../../utils');
module.exports = createNonTransactionalMigration(
async function up(knex) {
if (knex.client.config.client === 'sqlite3') {
logging.warn('Skipping migration for SQLite3');
return;
}
logging.info('Changing posts.email_recipient_filter column from VARCHAR(50) to TEXT');
await knex.schema.alterTable('posts', function (table) {
table.text('email_recipient_filter').alter();
});
},
async function down() {
logging.warn('Not changing posts.email_recipient_filter column');
}
);

View file

@ -0,0 +1,18 @@
const logging = require('@tryghost/logging');
const {createNonTransactionalMigration} = require('../../utils');
module.exports = createNonTransactionalMigration(
async function up(knex) {
if (knex.client.config.client === 'sqlite3') {
logging.warn('Skipping migration for SQLite3');
return;
}
logging.info('Changing emails.recipient_filter column from VARCHAR(50) to TEXT');
await knex.schema.alterTable('emails', function (table) {
table.text('recipient_filter').alter();
});
},
async function down() {
logging.warn('Not changing emails.recipient_filter column');
}
);

View file

@ -30,8 +30,8 @@ module.exports = {
defaultTo: 'public'
},
email_recipient_filter: {
type: 'string',
maxlength: 50,
type: 'text',
maxlength: 1000000000,
nullable: false,
defaultTo: 'none'
},
@ -598,8 +598,8 @@ module.exports = {
validations: {isIn: [['pending', 'submitting', 'submitted', 'failed']]}
},
recipient_filter: {
type: 'string',
maxlength: 50,
type: 'text',
maxlength: 1000000000,
nullable: false,
defaultTo: 'status:-free'
},

View file

@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '95bef616ba2bf7b91a99c627bbc591a3';
const currentSchemaHash = '9e4eeb5c260047fe21d1f93c523bd771';
const currentFixturesHash = 'beb040c0376a492c2a44767fdd825a3e';
const currentSettingsHash = 'd73b63e33153c9256bca42ebfd376779';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';