Skip to content

Commit

Permalink
fix(migration): ignore prefixing inside migrations
Browse files Browse the repository at this point in the history
Schema commands should never prefix the table name and instead the end-users should provide the

actual tablename, also fixed where lucid itself was selecting migrations table with prefix

Closes #105
  • Loading branch information
thetutlage committed Feb 25, 2017
1 parent fc6439f commit 5aebc5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Migrations/Mixins/Migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Migrate._mapMigrationsToActions = function (migrationsList, direction) {
* @private
*/
Migrate._getMigratedFiles = function () {
return this.database.select('name as name').from(this.migrationsTable).orderBy('name').pluck('name')
return this.database.select('name as name').withoutPrefix().from(this.migrationsTable).orderBy('name').pluck('name')
}

/**
Expand Down
20 changes: 20 additions & 0 deletions test/unit/migrations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,4 +843,24 @@ describe('Migrations', function () {
yield runner.database.schema.dropTable('adonis_migrations')
yield runner.database.schema.dropTable('my_users')
})

it('should ignore prefix when selecting migrations table', function * () {
Database._setConfigProvider(config.withPrefix)
const Runner = new Migrations(Database, Config)
const runner = new Runner()
class Users extends Schema {
up () {
this.create('ad_users', (table) => {
table.increments()
})
}
}
const migrations = {'2016-04-21': Users}
yield runner.up(migrations)
yield runner.up(migrations)
const myUsersInfo = yield runner.database.table('users').columnInfo()
expect(myUsersInfo.id).be.an('object')
yield runner.database.schema.dropTable('adonis_migrations')
yield runner.database.schema.dropTable('ad_users')
})
})

0 comments on commit 5aebc5b

Please sign in to comment.