This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
forked from RadoslavGatev/Ghost-Azure
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
103 changed files
with
1,700 additions
and
1,646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
core/built/assets/ghost-dark-06490535a152fed03c37deab503b6b8e.css
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
core/built/assets/ghost-dark-9b08cbf5f946c613d53078b7dc0e4abc.css
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
core/built/assets/ghost.min-3a4d4a32ec8c3202fb84555bfc4ff07f.css
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
core/built/assets/ghost.min-87dcc5855d1ebbf07c16a5d766b1c88b.css
Large diffs are not rendered by default.
Oops, something went wrong.
197 changes: 106 additions & 91 deletions
197
...t.min-576a456dcad5dddbdab6de6aa934dc9f.js → ...t.min-b4187f4b25eb5b6f59c3e9c3f6215fca.js
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 53 additions & 43 deletions
96
...r.min-927298149aff3b1dd094bfb6b92f6de3.js → ...r.min-b6b84abab9c092983d4c6fbfc7ad7551.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
const Promise = require('bluebird'); | ||
const storage = require('../../adapters/storage'); | ||
|
||
module.exports = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/2.15/1-add-type-column-to-integrations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/2.2/2-add-integrations-and-api-key-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/2.27/3-add-subdirectory-to-relative-canonical-urls.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 19 additions & 55 deletions
74
core/server/data/migrations/versions/2.29/1-add-post-page-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,20 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb}) { | ||
return function columnMigrations({transacting}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
// has to be passed directly in case of migration to 3.0 | ||
// ref: https://github.com/TryGhost/Ghost/commit/9d7190d69255ac011848c6bf654886be81abeedc#diff-c20cac44dad77922cf53ffd7b094cd8cL22 | ||
const columnSpec = { | ||
type: 'bool', | ||
nullable: false, | ||
defaultTo: false | ||
}; | ||
|
||
return operation(table, column, transacting, columnSpec); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = function (options) { | ||
return options.transacting.schema.hasColumn('posts', 'type').then((hasTypeColumn) => { | ||
if (!hasTypeColumn) { | ||
// no-op'd post.page->post.type migrations were never run | ||
return Promise.resolve(); | ||
const {createNonTransactionalMigration} = require('../../utils'); | ||
const commands = require('../../../schema/commands'); | ||
|
||
module.exports = createNonTransactionalMigration( | ||
commands.createColumnMigration({ | ||
table: 'posts', | ||
column: 'page', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
type: 'bool', | ||
nullable: false, | ||
defaultTo: false | ||
} | ||
|
||
return createColumnMigration({ | ||
table: 'posts', | ||
column: 'page', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
})(options); | ||
}); | ||
}; | ||
|
||
// `up` only runs in order to fix a previous migration so we don't want to do | ||
// anything in `down` because it would put previously-fine sites into the wrong | ||
// state | ||
module.exports.down = () => Promise.resolve(); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; | ||
}), | ||
() => Promise.resolve() | ||
); |
63 changes: 15 additions & 48 deletions
63
core/server/data/migrations/versions/2.29/3-remove-page-type-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,15 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb, columnDefinition}) { | ||
return function columnMigrations({transacting}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
return operation(table, column, transacting, columnDefinition); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = function (options) { | ||
return options.transacting.schema.hasColumn('posts', 'type').then((hasTypeColumn) => { | ||
if (!hasTypeColumn) { | ||
// no-op'd post.page->post.type migrations were never run | ||
return Promise.resolve(); | ||
} | ||
|
||
return createColumnMigration({ | ||
table: 'posts', | ||
column: 'type', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
})(options); | ||
}); | ||
}; | ||
|
||
// `up` only runs in order to fix a previous migration so we don't want to do | ||
// anything in `down` because it would put previously-fine sites into the wrong | ||
// state | ||
module.exports.down = () => Promise.resolve(); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; | ||
const {createNonTransactionalMigration} = require('../../utils'); | ||
const commands = require('../../../schema/commands'); | ||
|
||
module.exports = createNonTransactionalMigration( | ||
commands.createColumnMigration({ | ||
table: 'posts', | ||
column: 'type', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}), | ||
() => Promise.resolve() | ||
); |
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/2.3/1-add-webhook-columns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 13 additions & 53 deletions
66
core/server/data/migrations/versions/2.31/1-remove-name-and-password-from-members-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,15 @@ | ||
const commands = require('../../../schema').commands; | ||
const {combineNonTransactionalMigrations, createDropColumnMigration} = require('../../utils'); | ||
|
||
module.exports = { | ||
|
||
up: commands.createColumnMigration({ | ||
table: 'members', | ||
column: 'password', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, { | ||
table: 'members', | ||
column: 'name', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}), | ||
|
||
down: commands.createColumnMigration({ | ||
table: 'members', | ||
column: 'password', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
type: 'string', | ||
maxlength: 60, | ||
nullable: true | ||
} | ||
}, { | ||
table: 'members', | ||
column: 'name', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: false, | ||
defaultTo: '' | ||
} | ||
module.exports = combineNonTransactionalMigrations( | ||
createDropColumnMigration('members', 'password', { | ||
type: 'string', | ||
maxlength: 60, | ||
nullable: true | ||
}), | ||
|
||
config: { | ||
transaction: true | ||
} | ||
}; | ||
createDropColumnMigration('members', 'name', { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: false, | ||
defaultTo: '' | ||
}) | ||
); |
33 changes: 6 additions & 27 deletions
33
core/server/data/migrations/versions/2.32/02-add-name-to-members-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = { | ||
|
||
up: commands.createColumnMigration({ | ||
table: 'members', | ||
column: 'name', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}), | ||
|
||
down: commands.createColumnMigration({ | ||
table: 'members', | ||
column: 'name', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}), | ||
|
||
config: { | ||
transaction: true | ||
} | ||
}; | ||
module.exports = createAddColumnMigration('members', 'name', { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: true | ||
}); |
33 changes: 6 additions & 27 deletions
33
core/server/data/migrations/versions/2.34/02-add-email-to-members-stripe-customers-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = { | ||
|
||
up: commands.createColumnMigration({ | ||
table: 'members_stripe_customers', | ||
column: 'email', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}), | ||
|
||
down: commands.createColumnMigration({ | ||
table: 'members_stripe_customers', | ||
column: 'email', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}), | ||
|
||
config: { | ||
transaction: true | ||
} | ||
}; | ||
module.exports = createAddColumnMigration('members_stripe_customers', 'email', { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: true | ||
}); |
33 changes: 6 additions & 27 deletions
33
core/server/data/migrations/versions/2.34/03-add-name-to-members-stripe-customers-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = { | ||
|
||
up: commands.createColumnMigration({ | ||
table: 'members_stripe_customers', | ||
column: 'name', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}), | ||
|
||
down: commands.createColumnMigration({ | ||
table: 'members_stripe_customers', | ||
column: 'name', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}), | ||
|
||
config: { | ||
transaction: true | ||
} | ||
}; | ||
module.exports = createAddColumnMigration('members_stripe_customers', 'name', { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: true | ||
}); |
33 changes: 6 additions & 27 deletions
33
core/server/data/migrations/versions/2.35/01-add-note-to-members-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = { | ||
|
||
up: commands.createColumnMigration({ | ||
table: 'members', | ||
column: 'note', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}), | ||
|
||
down: commands.createColumnMigration({ | ||
table: 'members', | ||
column: 'note', | ||
dbIsInCorrectState(hasColumn) { | ||
return hasColumn === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}), | ||
|
||
config: { | ||
transaction: true | ||
} | ||
}; | ||
module.exports = createAddColumnMigration('members', 'note', { | ||
type: 'string', | ||
maxlength: 2000, | ||
nullable: true | ||
}); |
92 changes: 14 additions & 78 deletions
92
core/server/data/migrations/versions/3.0/01-remove-user-ghost-auth-columns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,14 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigrations(migrations) { | ||
return function columnMigrations({transacting}) { | ||
return Promise.each(migrations, function ({table, column, dbIsInCorrectState, operation, operationVerb, columnDefinition}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
return operation(table, column, transacting, columnDefinition); | ||
} | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = createColumnMigrations([ | ||
{ | ||
table: 'users', | ||
column: 'ghost_auth_access_token', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}, | ||
{ | ||
table: 'users', | ||
column: 'ghost_auth_id', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
} | ||
]); | ||
|
||
module.exports.down = createColumnMigrations([ | ||
{ | ||
table: 'users', | ||
column: 'ghost_auth_access_token', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 32 | ||
} | ||
}, | ||
{ | ||
table: 'users', | ||
column: 'ghost_auth_id', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 24 | ||
} | ||
} | ||
]); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; | ||
const {combineNonTransactionalMigrations, createDropColumnMigration} = require('../../utils'); | ||
|
||
module.exports = combineNonTransactionalMigrations( | ||
createDropColumnMigration('users', 'ghost_auth_access_token', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 32 | ||
}), | ||
createDropColumnMigration('users', 'ghost_auth_id', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 24 | ||
}) | ||
); |
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.0/02-drop-token-auth-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.0/03-drop-client-auth-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.0/05-populate-posts-meta-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 19 additions & 166 deletions
185
core/server/data/migrations/versions/3.0/06-remove-posts-meta-columns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,191 +1,44 @@ | ||
const commands = require('../../../schema').commands; | ||
const {combineNonTransactionalMigrations, createDropColumnMigration} = require('../../utils'); | ||
|
||
module.exports.up = commands.createColumnMigration({ | ||
table: 'posts', | ||
column: 'meta_title', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'meta_description', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'og_image', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'og_title', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'og_description', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'twitter_image', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'twitter_title', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'twitter_description', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Dropping' | ||
}); | ||
|
||
module.exports.down = commands.createColumnMigration({ | ||
table: 'posts', | ||
column: 'meta_title', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
module.exports = combineNonTransactionalMigrations( | ||
createDropColumnMigration('posts', 'meta_title', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 2000 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'meta_description', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'meta_description', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 2000 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'og_image', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'og_image', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 2000 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'og_title', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'og_title', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 300 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'og_description', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'og_description', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 500 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'twitter_image', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'twitter_image', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 2000 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'twitter_title', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'twitter_title', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 300 | ||
} | ||
}, | ||
{ | ||
table: 'posts', | ||
column: 'twitter_description', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
}), | ||
createDropColumnMigration('posts', 'twitter_description', { | ||
type: 'string', | ||
nullable: true, | ||
maxlength: 500 | ||
} | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; | ||
}) | ||
); |
48 changes: 6 additions & 42 deletions
48
core/server/data/migrations/versions/3.0/07-add-posts-type-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,8 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb}) { | ||
return function columnMigrations({transacting}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
return operation(table, column, transacting); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = createColumnMigration({ | ||
table: 'posts', | ||
column: 'type', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('posts', 'type', { | ||
type: 'string', | ||
maxlength: 50, | ||
nullable: false, | ||
defaultTo: 'post' | ||
}); | ||
|
||
module.exports.down = createColumnMigration({ | ||
table: 'posts', | ||
column: 'type', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
52 changes: 5 additions & 47 deletions
52
core/server/data/migrations/versions/3.0/09-remove-posts-page-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,7 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
const {createDropColumnMigration} = require('../../utils'); | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb, columnDefinition}) { | ||
return function columnMigrations({transacting}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
return operation(table, column, transacting, columnDefinition); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = createColumnMigration({ | ||
table: 'posts', | ||
column: 'page', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
module.exports = createDropColumnMigration('posts', 'page', { | ||
type: 'bool', | ||
nullable: false, | ||
defaultTo: false | ||
}); | ||
|
||
module.exports.down = createColumnMigration({ | ||
table: 'posts', | ||
column: 'page', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding', | ||
columnDefinition: { | ||
type: 'bool', | ||
nullable: false, | ||
defaultTo: false | ||
} | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.0/12-populate-members-table-from-subscribers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.0/13-drop-subscribers-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 5 additions & 23 deletions
28
core/server/data/migrations/versions/3.1/01-add-send-email-when-published-to-posts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports.up = commands.createColumnMigration({ | ||
table: 'posts', | ||
column: 'send_email_when_published', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('posts', 'send_email_when_published', { | ||
type: 'bool', | ||
nullable: true, | ||
defaultTo: false | ||
}); | ||
|
||
module.exports.down = commands.createColumnMigration({ | ||
table: 'posts', | ||
column: 'send_email_when_published', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
28 changes: 5 additions & 23 deletions
28
core/server/data/migrations/versions/3.1/02-add-email-subject-to-posts-meta.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports.up = commands.createColumnMigration({ | ||
table: 'posts_meta', | ||
column: 'email_subject', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('posts_meta', 'email_subject', { | ||
type: 'string', | ||
maxlength: 300, | ||
nullable: true | ||
}); | ||
|
||
module.exports.down = commands.createColumnMigration({ | ||
table: 'posts_meta', | ||
column: 'email_subject', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
47 changes: 5 additions & 42 deletions
47
core/server/data/migrations/versions/3.1/04-add-subscribed-flag-to-members.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,7 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb}) { | ||
return function columnMigrations({transacting}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
return operation(table, column, transacting); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = createColumnMigration({ | ||
table: 'members', | ||
column: 'subscribed', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('members', 'subscribed', { | ||
type: 'bool', | ||
nullable: true, | ||
defaultTo: true | ||
}); | ||
|
||
module.exports.down = createColumnMigration({ | ||
table: 'members', | ||
column: 'subscribed', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
48 changes: 6 additions & 42 deletions
48
core/server/data/migrations/versions/3.1/07-add-uuid-field-to-members.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,8 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
const createLog = type => msg => logging[type](msg); | ||
|
||
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb}) { | ||
return function columnMigrations({transacting}) { | ||
return transacting.schema.hasColumn(table, column) | ||
.then(dbIsInCorrectState) | ||
.then((isInCorrectState) => { | ||
const log = createLog(isInCorrectState ? 'warn' : 'info'); | ||
|
||
log(`${operationVerb} ${table}.${column}`); | ||
|
||
if (!isInCorrectState) { | ||
return operation(table, column, transacting); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
module.exports.up = createColumnMigration({ | ||
table: 'members', | ||
column: 'uuid', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('members', 'uuid', { | ||
type: 'string', | ||
maxlength: 36, | ||
nullable: true, | ||
unique: true | ||
}); | ||
|
||
module.exports.down = createColumnMigration({ | ||
table: 'members', | ||
column: 'uuid', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
29 changes: 6 additions & 23 deletions
29
core/server/data/migrations/versions/3.1/10-add-email-error-data-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports.up = commands.createColumnMigration({ | ||
table: 'emails', | ||
column: 'error_data', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('emails', 'error_data', { | ||
type: 'text', | ||
maxlength: 1000000000, | ||
fieldtype: 'long', | ||
nullable: true | ||
}); | ||
|
||
module.exports.down = commands.createColumnMigration({ | ||
table: 'emails', | ||
column: 'error_data', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
28 changes: 5 additions & 23 deletions
28
core/server/data/migrations/versions/3.2/01-add-cancel-at-period-end-to-subscriptions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports.up = commands.createColumnMigration({ | ||
table: 'members_stripe_customers_subscriptions', | ||
column: 'cancel_at_period_end', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
module.exports = createAddColumnMigration('members_stripe_customers_subscriptions', 'cancel_at_period_end', { | ||
type: 'bool', | ||
nullable: false, | ||
defaultTo: false | ||
}); | ||
|
||
module.exports.down = commands.createColumnMigration({ | ||
table: 'members_stripe_customers_subscriptions', | ||
column: 'cancel_at_period_end', | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
64 changes: 15 additions & 49 deletions
64
core/server/data/migrations/versions/3.22/03-add-group-and-flags-to-settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,15 @@ | ||
const commands = require('../../../schema').commands; | ||
|
||
module.exports = { | ||
config: { | ||
transaction: true | ||
}, | ||
|
||
async up(options) { | ||
function addSettingsColumn(column) { | ||
return { | ||
table: 'settings', | ||
column, | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}; | ||
} | ||
|
||
const columnMigration = commands.createColumnMigration( | ||
addSettingsColumn('group'), | ||
addSettingsColumn('flags') | ||
); | ||
|
||
return columnMigration(options); | ||
}, | ||
|
||
async down(options) { | ||
function removeSettingsColumn(column) { | ||
return { | ||
table: 'settings', | ||
column, | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}; | ||
} | ||
|
||
const columnMigration = commands.createColumnMigration( | ||
removeSettingsColumn('group'), | ||
removeSettingsColumn('flags') | ||
); | ||
|
||
return columnMigration(options); | ||
} | ||
}; | ||
const {createAddColumnMigration, combineNonTransactionalMigrations} = require('../../utils'); | ||
|
||
module.exports = combineNonTransactionalMigrations( | ||
createAddColumnMigration('settings', 'group', { | ||
type: 'string', | ||
maxlength: 50, | ||
nullable: false, | ||
defaultTo: 'core' | ||
}), | ||
createAddColumnMigration('settings', 'flags', { | ||
type: 'string', | ||
maxlength: 50, | ||
nullable: true | ||
}) | ||
); |
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.22/04-populate-settings-groups-and-flags.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 23 additions & 66 deletions
89
core/server/data/migrations/versions/3.23/04-add-meta-columns-to-tags-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,54 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration, combineNonTransactionalMigrations} = require('../../utils'); | ||
|
||
const newColumns = [{ | ||
column: 'og_image', | ||
columnDefinition: { | ||
module.exports = combineNonTransactionalMigrations( | ||
createAddColumnMigration('tags', 'og_image', { | ||
type: 'string', | ||
maxlength: 2000, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'og_title', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'og_title', { | ||
type: 'string', | ||
maxlength: 300, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'og_description', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'og_description', { | ||
type: 'string', | ||
maxlength: 500, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'twitter_image', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'twitter_image', { | ||
type: 'string', | ||
maxlength: 2000, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'twitter_title', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'twitter_title', { | ||
type: 'string', | ||
maxlength: 300, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'twitter_description', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'twitter_description', { | ||
type: 'string', | ||
maxlength: 500, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'codeinjection_head', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'codeinjection_head', { | ||
type: 'text', | ||
maxlength: 65535, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'codeinjection_foot', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'codeinjection_foot', { | ||
type: 'text', | ||
maxlength: 65535, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'canonical_url', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'canonical_url', { | ||
type: 'string', | ||
maxlength: 2000, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'accent_color', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('tags', 'accent_color', { | ||
type: 'string', | ||
maxlength: 50, | ||
nullable: true | ||
} | ||
}]; | ||
|
||
module.exports = { | ||
config: { | ||
transaction: true | ||
}, | ||
|
||
up: commands.createColumnMigration(...newColumns.map((column) => { | ||
return Object.assign({}, column, { | ||
table: 'tags', | ||
dbIsInCorrectState: hasColumn => hasColumn === true, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}); | ||
})), | ||
|
||
down: commands.createColumnMigration(...newColumns.map((column) => { | ||
return Object.assign({}, column, { | ||
table: 'tags', | ||
dbIsInCorrectState: hasColumn => hasColumn === false, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
})) | ||
}; | ||
}) | ||
); |
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.24/01-populate-group-for-new-portal-settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/server/data/migrations/versions/3.33/01-add-email-recipients-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 7 additions & 34 deletions
41
core/server/data/migrations/versions/3.35/01-add-address-columns-to-emails-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,14 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration, combineNonTransactionalMigrations} = require('../../utils'); | ||
|
||
const newColumns = [{ | ||
column: 'from', | ||
columnDefinition: { | ||
module.exports = combineNonTransactionalMigrations( | ||
createAddColumnMigration('emails', 'from', { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: true | ||
} | ||
}, { | ||
column: 'reply_to', | ||
columnDefinition: { | ||
}), | ||
createAddColumnMigration('emails', 'reply_to', { | ||
type: 'string', | ||
maxlength: 191, | ||
nullable: true | ||
} | ||
}]; | ||
|
||
module.exports = { | ||
config: { | ||
transaction: true | ||
}, | ||
|
||
up: commands.createColumnMigration(...newColumns.map((column) => { | ||
return Object.assign({}, column, { | ||
table: 'emails', | ||
dbIsInCorrectState: hasColumn => hasColumn === true, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}); | ||
})), | ||
|
||
down: commands.createColumnMigration(...newColumns.map((column) => { | ||
return Object.assign({}, column, { | ||
table: 'emails', | ||
dbIsInCorrectState: hasColumn => hasColumn === false, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
}); | ||
})) | ||
}; | ||
}) | ||
); |
8 changes: 8 additions & 0 deletions
8
core/server/data/migrations/versions/3.38/01-add-email-recipient-filter-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = createAddColumnMigration('posts', 'email_recipient_filter', { | ||
type: 'string', | ||
maxlength: 50, | ||
nullable: false, | ||
defaultTo: 'none' | ||
}); |
34 changes: 34 additions & 0 deletions
34
core/server/data/migrations/versions/3.38/02-populate-email-recipient-filter-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const {createTransactionalMigration} = require('../../utils'); | ||
const logging = require('../../../../../shared/logging'); | ||
|
||
module.exports = createTransactionalMigration( | ||
async function up(connection) { | ||
logging.info('Updating email_recipient_filter values based on visibility and send_email_when_published'); | ||
await connection('posts') | ||
.update('email_recipient_filter', 'paid') | ||
.where({ | ||
send_email_when_published: true, | ||
visibility: 'paid' | ||
}); | ||
|
||
await connection('posts') | ||
.update('email_recipient_filter', 'all') | ||
.where({ | ||
send_email_when_published: true, | ||
visibility: 'members' | ||
}); | ||
|
||
await connection('posts') | ||
.update('email_recipient_filter', 'all') | ||
.where({ | ||
send_email_when_published: true, | ||
visibility: 'public' | ||
}); | ||
}, | ||
|
||
async function down(connection) { | ||
logging.info('Updating email_recipient_filter values to none'); | ||
await connection('posts') | ||
.update('email_recipient_filter', 'none'); | ||
} | ||
); |
8 changes: 8 additions & 0 deletions
8
core/server/data/migrations/versions/3.38/03-add-recipient-filter-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = createAddColumnMigration('emails', 'recipient_filter', { | ||
type: 'string', | ||
maxlength: 50, | ||
nullable: false, | ||
defaultTo: 'paid' | ||
}); |
35 changes: 35 additions & 0 deletions
35
core/server/data/migrations/versions/3.38/04-populate-recipient-filter-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const {createTransactionalMigration} = require('../../utils'); | ||
const logging = require('../../../../../shared/logging'); | ||
|
||
module.exports = createTransactionalMigration( | ||
async function up(connection) { | ||
logging.info('Updating emails.recipient_filter values based on posts.visibility'); | ||
|
||
const paidPostIds = (await connection('posts') | ||
.select('id') | ||
.where('visibility', 'paid')).map(row => row.id); | ||
|
||
const membersPostIds = (await connection('posts') | ||
.select('id') | ||
.where('visibility', 'members')).map(row => row.id); | ||
|
||
const publicPostIds = (await connection('posts') | ||
.select('id') | ||
.where('visibility', 'public')).map(row => row.id); | ||
|
||
await connection('emails') | ||
.update('recipient_filter', 'paid') | ||
.whereIn('post_id', paidPostIds); | ||
|
||
await connection('emails') | ||
.update('recipient_filter', 'all') | ||
.whereIn('post_id', membersPostIds.concat(publicPostIds)); | ||
}, | ||
|
||
async function down(connection) { | ||
logging.info('Updating emails.recipient_filter values to paid'); | ||
await connection('emails') | ||
.update('recipient_filter', 'paid'); | ||
} | ||
); | ||
|
7 changes: 7 additions & 0 deletions
7
core/server/data/migrations/versions/3.38/05-add-emails-track-opens-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
module.exports = createAddColumnMigration('emails', 'track_opens', { | ||
type: 'bool', | ||
nullable: false, | ||
defaultTo: false | ||
}); |
16 changes: 16 additions & 0 deletions
16
core/server/data/migrations/versions/3.38/06-add-newsletter-settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const {createTransactionalMigration} = require('../../utils'); | ||
|
||
module.exports = createTransactionalMigration( | ||
|
||
async function up(connection) { | ||
logging.info('Updating newsletter settings - newsletter_show_badge, newsletter_show_header, newsletter_body_font_category, newsletter_footer_content - to newsletter group'); | ||
await connection('settings') | ||
.whereIn('key', ['newsletter_show_badge', 'newsletter_show_header', 'newsletter_body_font_category', 'newsletter_footer_content']) | ||
.update({ | ||
group: 'newsletter' | ||
}); | ||
}, | ||
|
||
async function down() {} | ||
); |
48 changes: 48 additions & 0 deletions
48
core/server/data/migrations/versions/3.38/07-migrate-newsletter-settings-from-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const {createTransactionalMigration} = require('../../utils'); | ||
const config = require('../../../../../shared/config'); | ||
const logging = require('../../../../../shared/logging'); | ||
|
||
module.exports = createTransactionalMigration( | ||
async function up(connection) { | ||
const emailTemplateConfig = config.get('members:emailTemplate'); | ||
|
||
logging.info('Updating newsletter_show_header setting from members.emailTemplate.showSiteHeader config'); | ||
await connection('settings') | ||
.update({ | ||
value: emailTemplateConfig.showSiteHeader ? 'true' : 'false' | ||
}) | ||
.where({ | ||
key: 'newsletter_show_header' | ||
}); | ||
|
||
logging.info('Updating newsletter_show_badge setting from members.emailTemplate.showPoweredBy config'); | ||
await connection('settings') | ||
.update({ | ||
value: emailTemplateConfig.showPoweredBy ? 'true' : 'false' | ||
}) | ||
.where({ | ||
key: 'newsletter_show_badge' | ||
}); | ||
}, | ||
|
||
async function down(connection) { | ||
logging.info('Updating newsletter_show_header setting to default "true"'); | ||
await connection('settings') | ||
.update({ | ||
value: 'true' | ||
}) | ||
.where({ | ||
key: 'newsletter_show_header' | ||
}); | ||
|
||
logging.info('Updating newsletter_show_badge setting to default "false"'); | ||
await connection('settings') | ||
.update({ | ||
value: 'true' | ||
}) | ||
.where({ | ||
key: 'newsletter_show_badge' | ||
}); | ||
} | ||
); | ||
|
25 changes: 25 additions & 0 deletions
25
...r/data/migrations/versions/3.38/08-repopulate-send-email-when-published-down-migration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
const {createTransactionalMigration} = require('../../utils'); | ||
|
||
module.exports = createTransactionalMigration( | ||
async function up() {}, | ||
|
||
async function down(connection) { | ||
logging.info('Setting "send_email_when_published" based on "email_recipient_filter"'); | ||
await connection('posts') | ||
.update({ | ||
send_email_when_published: true | ||
}) | ||
.whereNot({ | ||
email_recipient_filter: 'none' | ||
}); | ||
|
||
await connection('posts') | ||
.update({ | ||
send_email_when_published: false | ||
}) | ||
.where({ | ||
email_recipient_filter: 'none' | ||
}); | ||
} | ||
); |
7 changes: 7 additions & 0 deletions
7
core/server/data/migrations/versions/3.38/09-remove-send-email-when-published-column.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const {createDropColumnMigration} = require('../../utils'); | ||
|
||
module.exports = createDropColumnMigration('posts', 'send_email_when_published', { | ||
type: 'bool', | ||
nullable: true, | ||
defaultTo: false | ||
}); |
31 changes: 5 additions & 26 deletions
31
core/server/data/migrations/versions/3.8/01-add-geolocation-to-members.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
const commands = require('../../../schema').commands; | ||
const {createAddColumnMigration} = require('../../utils'); | ||
|
||
const table = 'members'; | ||
const column = 'geolocation'; | ||
|
||
module.exports.up = commands.createColumnMigration({ | ||
table, | ||
column, | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === true; | ||
}, | ||
operation: commands.addColumn, | ||
operationVerb: 'Adding' | ||
}); | ||
|
||
module.exports.down = commands.createColumnMigration({ | ||
table, | ||
column, | ||
dbIsInCorrectState(columnExists) { | ||
return columnExists === false; | ||
}, | ||
operation: commands.dropColumn, | ||
operationVerb: 'Removing' | ||
module.exports = createAddColumnMigration('members', 'geolocation', { | ||
type: 'string', | ||
maxlength: 2000, | ||
nullable: true | ||
}); | ||
|
||
module.exports.config = { | ||
transaction: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const logging = require('../../../../../shared/logging'); | ||
|
||
const helloJob = () => { | ||
logging.info('Starting hello job'); | ||
|
||
logging.info('Gonna say "hi" in 5 seconds'); | ||
|
||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
logging.info('hi!'); | ||
logging.info('Ending hello job run.'); | ||
resolve(); | ||
}, 5 * 1000); | ||
}); | ||
}; | ||
|
||
module.exports = helloJob; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters