Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump knex-migrator to version 3.1.1 #9199

Merged
merged 20 commits into from
Dec 5, 2017
Merged

Conversation

kirrg001
Copy link
Contributor

@kirrg001 kirrg001 commented Nov 1, 2017

no issue

Hold. I don't want to break everything, it's a sensitive update. So i'll let my brain a little time over the weekend and see if i can discover any problems e.g. breaking changes with CLI, Global Installations, Ghost...

@kirrg001 kirrg001 changed the title [WIP] Bump knex-migrator to version 3.0.0 [HOLD] Bump knex-migrator to version 3.0.0 Nov 2, 2017
@kirrg001
Copy link
Contributor Author

kirrg001 commented Nov 7, 2017

I'll try to find any problems till the next release on Thursday. e.g. what happens if your global installation is on 2.x. Furthermore, the CLI needs to be updated as well and released. Have to manage and test a couple of things before merging this. It's a sensitive change.

@kirrg001
Copy link
Contributor Author

This is on hold till we release a new CLI version including the removal of it's knex-migrator dependency and a migration command for the renewal of ssl certificates. Both will hopefully ensure that people will update to the latest CLI version and then we can merge this breaking change.

no issue

- adapt major changes
- adapt migration scripts
- make the scripts easier
- ensure rollback of fixtures works

[ci skip]
@kirrg001
Copy link
Contributor Author

kirrg001 commented Dec 4, 2017

First test succeeded. Tested with SQlite3 and MySQL.

CLI 1.2.1
Ghost 1.5.0

ghost update --zip 1.18.3

Has thrown an error, which is documented here.
Rolling back to 1.5.0 with ghost update --rollback works as expected. After upgrading the CLI to the latest and re-running ghost update --zip 1.18.3, the blog successfully migrated from 1.5.0 to 1.18.3.

@kirrg001
Copy link
Contributor Author

kirrg001 commented Dec 4, 2017

Second test succeeded.

Install a new blog with CLI > 1.3.0 and this PR.
Install a blog on 1.6.0 with CLI > 1.3.0 and then migrate to this PR.

@kirrg001 kirrg001 changed the title [HOLD] Bump knex-migrator to version 3.0.0 Bump knex-migrator to version 3.0.0 Dec 5, 2017
@kirrg001 kirrg001 changed the title Bump knex-migrator to version 3.0.0 Bump knex-migrator to version 3.1.1 Dec 5, 2017
@kirrg001 kirrg001 merged commit 0bb81bb into TryGhost:master Dec 5, 2017
@aemonge
Copy link

aemonge commented Mar 5, 2018

The latest version of knex-migrator 3.1.3 doesn't work.

Please update the documentation to install the 3.1.1 which works ;)

@kirrg001
Copy link
Contributor Author

kirrg001 commented Mar 5, 2018

@aemonge What doesn't work?

@aemonge
Copy link

aemonge commented Mar 6, 2018

This is the error that I've fixed changing the version of knex-migrator:
(for both cases I did a fresh install rm -rf node_modules; npm i before each attempt. Also the knex package is locally installed)

 ⚙ aemonge@osboxes  ~/usr/tmp/ghost  knex-migrator --version
3.1.4
 ⚙ aemonge@osboxes  ~/usr/tmp/ghost  knex-migrator init --mgpath node_modules/ghost
[2018-03-06 09:14:58] INFO Creating table: posts
[2018-03-06 09:14:58] INFO Creating table: users
[2018-03-06 09:14:58] INFO Creating table: roles
[2018-03-06 09:14:58] INFO Creating table: roles_users
[2018-03-06 09:14:58] INFO Creating table: permissions
[2018-03-06 09:14:58] INFO Creating table: permissions_users
[2018-03-06 09:14:58] INFO Creating table: permissions_roles
[2018-03-06 09:14:58] INFO Creating table: permissions_apps
[2018-03-06 09:14:58] INFO Creating table: settings
[2018-03-06 09:14:58] INFO Creating table: tags
[2018-03-06 09:14:58] INFO Creating table: posts_tags
[2018-03-06 09:14:58] INFO Creating table: apps
[2018-03-06 09:14:58] INFO Creating table: app_settings
[2018-03-06 09:14:58] INFO Creating table: app_fields
[2018-03-06 09:14:58] INFO Creating table: clients
[2018-03-06 09:14:58] INFO Creating table: client_trusted_domains
[2018-03-06 09:14:58] INFO Creating table: accesstokens
[2018-03-06 09:14:58] INFO Creating table: refreshtokens
[2018-03-06 09:14:58] INFO Creating table: subscribers
[2018-03-06 09:14:58] INFO Creating table: invites
[2018-03-06 09:14:58] INFO Creating table: brute
[2018-03-06 09:14:58] INFO Creating table: webhooks
[2018-03-06 09:14:58] INFO Model: Post
[2018-03-06 09:14:58] ERROR

NAME: MigrationScriptError
MESSAGE: this.builder.queryContext is not a function

level:normal

Error occurred while executing the following migration: 2-create-fixtures.js
MigrationScriptError: this.builder.queryContext is not a function
    at MigrationScriptError.KnexMigrateError (/home/aemonge/usr/tmp/ghost/node_modules/knex-migrator/lib/errors.js:9:26)
    at new MigrationScriptError (/home/aemonge/usr/tmp/ghost/node_modules/knex-migrator/lib/errors.js:28:26)
    at /home/aemonge/usr/tmp/ghost/node_modules/knex-migrator/lib/index.js:586:19
    at tryCatcher (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:763:18)
    at tryOnImmediate (timers.js:734:5)
    at processImmediate (timers.js:716:5)

TypeError: this.builder.queryContext is not a function
    at Formatter.wrapAsIdentifier (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/formatter.js:147:37)
    at Formatter.wrapString (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/formatter.js:246:27)
    at Formatter.wrap (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/formatter.js:142:21)
    at Formatter.wrapString (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/formatter.js:244:27)
    at Formatter.wrap (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/formatter.js:142:21)
    at Formatter.columnize (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/formatter.js:57:19)
    at QueryCompiler_SQLite3.columns (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/query/compiler.js:247:35)
    at /home/aemonge/usr/tmp/ghost/node_modules/knex/lib/query/compiler.js:167:31
    at Array.map (<anonymous>)
    at QueryCompiler_SQLite3.select (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/query/compiler.js:166:33)
    at QueryCompiler_SQLite3.toSQL (/home/aemonge/usr/tmp/ghost/node_modules/knex/lib/query/compiler.js:114:27)
    at Builder.toSQL (/home/aemonge/usr/tmp/ghost/node_modules/ghost/node_modules/knex/lib/query/builder.js:115:44)
    at /home/aemonge/usr/tmp/ghost/node_modules/knex/lib/runner.js:52:32
    at tryCatcher (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at /home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/using.js:185:26
    at tryCatcher (/home/aemonge/usr/tmp/ghost/node_modules/bluebird/js/release/util.js:16:23)

And this is the fixed output

 ✘ ⚙ aemonge@osboxes  ~/usr/tmp/ghost  knex-migrator --version
3.1.1
 ⚙ aemonge@osboxes  ~/usr/tmp/ghost  knex-migrator init --mgpath node_modules/ghost
[2018-03-06 09:19:25] INFO Creating table: posts
[2018-03-06 09:19:25] INFO Creating table: users
[2018-03-06 09:19:25] INFO Creating table: roles
[2018-03-06 09:19:25] INFO Creating table: roles_users
[2018-03-06 09:19:25] INFO Creating table: permissions
[2018-03-06 09:19:25] INFO Creating table: permissions_users
[2018-03-06 09:19:25] INFO Creating table: permissions_roles
[2018-03-06 09:19:25] INFO Creating table: permissions_apps
[2018-03-06 09:19:25] INFO Creating table: settings
[2018-03-06 09:19:25] INFO Creating table: tags
[2018-03-06 09:19:25] INFO Creating table: posts_tags
[2018-03-06 09:19:25] INFO Creating table: apps
[2018-03-06 09:19:25] INFO Creating table: app_settings
[2018-03-06 09:19:25] INFO Creating table: app_fields
[2018-03-06 09:19:25] INFO Creating table: clients
[2018-03-06 09:19:25] INFO Creating table: client_trusted_domains
[2018-03-06 09:19:25] INFO Creating table: accesstokens
[2018-03-06 09:19:25] INFO Creating table: refreshtokens
[2018-03-06 09:19:25] INFO Creating table: subscribers
[2018-03-06 09:19:25] INFO Creating table: invites
[2018-03-06 09:19:25] INFO Creating table: brute
[2018-03-06 09:19:25] INFO Creating table: webhooks
[2018-03-06 09:19:25] INFO Model: Post
[2018-03-06 09:19:26] INFO Model: Tag
[2018-03-06 09:19:26] INFO Model: Client
[2018-03-06 09:19:26] INFO Model: Role
[2018-03-06 09:19:26] INFO Model: Permission
[2018-03-06 09:19:26] INFO Model: User
[2018-03-06 09:19:27] INFO Relation: Role to Permission
[2018-03-06 09:19:27] INFO Relation: Post to Tag
[2018-03-06 09:19:27] INFO Relation: User to Role
[2018-03-06 09:19:28] INFO Finished database init!

@kirrg001
Copy link
Contributor Author

kirrg001 commented Mar 9, 2018

@aemonge

Please note: we only support installing dependencies with yarn. There is no package lock file for npm, this can caused wrong dependency trees.

knex-migrator 3.1.4 has bumped knex to the latest version. Latest Ghost master uses 3.1.3, which is correct. The global knex-migrator prefers the local version installed. So i don't see any problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants