adonisjs-hackathon-starter icon indicating copy to clipboard operation
adonisjs-hackathon-starter copied to clipboard

error: `migration:run` is not a registered comman

Open barak-haviv opened this issue 7 years ago • 6 comments

I Got this after following the installation instruction. node --version v8.10.0

barak-haviv avatar Mar 31 '18 07:03 barak-haviv

@barak-haviv what is your node version?

iamraphson avatar Mar 31 '18 07:03 iamraphson

same here,

adonis cli: 4.0.4 node: v9.10.1 npm: 5.6.0

on mac OS High Sierra - 10.13.2 Homebrew 1.5.13

2peter3 avatar Mar 31 '18 14:03 2peter3

@barak-haviv change "version": "4.1", to "version": "4.1.5",

in package.json

and migration works, but with warnings...: Knex:warning - Use async .hasTable to check if table exists and then use plain .createTable. Since .createTableIfNotExists actually just generates plain "CREATE TABLE IF NOT EXIST..." query it will not work correctly if there are any alter table queries generated for columns afterwards. To not break old migrations this function is left untouched for now, but it should not be used when writing new code and it is removed from documentation. Knex:warning - Use async .hasTable to check if table exists and then use plain .createTable. Since .createTableIfNotExists actually just generates plain "CREATE TABLE IF NOT EXIST..." query it will not work correctly if there are any alter table queries generated for columns afterwards. To not break old migrations this function is left untouched for now, but it should not be used when writing new code and it is removed from documentation. Knex:warning - Use async .hasTable to check if table exists and then use plain .createTable. Since .createTableIfNotExists actually just generates plain "CREATE TABLE IF NOT EXIST..." query it will not work correctly if there are any alter table queries generated for columns afterwards. To not break old migrations this function is left untouched for now, but it should not be used when writing new code and it is removed from documentation.

2peter3 avatar Mar 31 '18 15:03 2peter3

@barak-haviv @2peter3 thanks. For the warnings, it's from a knex lib used by @adonisjs/lucid. i don't know the cause but an issue has been raised https://github.com/iamraphson/adonisjs-hackathon-starter/issues/4

iamraphson avatar Apr 01 '18 08:04 iamraphson

@barak-haviv @2peter3 the warning is normal according to https://github.com/adonisjs/adonis-lucid/issues/304 so I will close this issue.

iamraphson avatar Jun 18 '18 12:06 iamraphson

@iamraphson It's probably better to do as recommended, change migrations to: if (!this.hasTable('users')) { this.createTable('users', table => { to prevent the warning message.

As a sidenote sqlite can't consume your alter table command, since it's not supporting alter.

Lastly, to be able to run it out of the box you might want to add "sqlite3": "^4.0.1", to package.json

**EDIT: createTable does not work anymore, it's create now. hasTable is an async method, so perhaps use createIfNotExists and dropIfExists

**EDIT2: Well, that will give a knex warning, they suggest use hasTable, so it needs a const exists = await this.hasTable('users')

Maxximus007 avatar Jun 28 '18 09:06 Maxximus007