Skip to content

Commit

Permalink
Merge branch 'release/4.0.20'
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Oct 3, 2017
2 parents 843a032 + 99e7fb4 commit 0db2a23
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<a name="4.0.20"></a>
## [4.0.20](https://github.com/adonisjs/adonis-lucid/compare/v4.0.19...v4.0.20) (2017-10-03)


### Bug Fixes

* **migrations:** use hasTable and createTable ([f12d51b](https://github.com/adonisjs/adonis-lucid/commit/f12d51b)), closes [#172](https://github.com/adonisjs/adonis-lucid/issues/172)
* **schema:** raw method should be knex.raw ([8cae109](https://github.com/adonisjs/adonis-lucid/commit/8cae109)), closes [#181](https://github.com/adonisjs/adonis-lucid/issues/181)



<a name="4.0.19"></a>
## [4.0.19](https://github.com/adonisjs/adonis-lucid/compare/v4.0.18...v4.0.19) (2017-10-01)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adonisjs/lucid",
"version": "4.0.19",
"version": "4.0.20",
"description": "SQL ORM built on top of Active Record pattern",
"main": "index.js",
"scripts": {
Expand Down
38 changes: 26 additions & 12 deletions src/Migration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ class Migration {
*
* @private
*/
_makeMigrationsTable () {
return this.db.schema.createTableIfNotExists(this._migrationsTable, (table) => {
table.increments()
table.string('name')
table.integer('batch')
table.timestamp('migration_time').defaultsTo(this.db.fn.now())
})
async _makeMigrationsTable () {
const hasTable = await this.db.schema.hasTable(this._migrationsTable)

/**
* We need to run 2 queries, since `createTableIfNotExists` doesn't
* work with postgres. Check following issue for more info.
*
* https://github.com/adonisjs/adonis-lucid/issues/172
*/
if (!hasTable) {
await this.db.schema.createTable(this._migrationsTable, (table) => {
table.increments()
table.string('name')
table.integer('batch')
table.timestamp('migration_time').defaultsTo(this.db.fn.now())
})
}
}

/**
Expand All @@ -61,11 +71,15 @@ class Migration {
*
* @private
*/
_makeLockTable () {
return this.db.schema.createTableIfNotExists(this._lockTable, (table) => {
table.increments()
table.boolean('is_locked')
})
async _makeLockTable () {
const hasTable = await this.db.schema.hasTable(this._lockTable)

if (!hasTable) {
await this.db.schema.createTable(this._lockTable, (table) => {
table.increments()
table.boolean('is_locked')
})
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Schema {
* @return {Object}
*/
raw (statement) {
return this.schema.raw(statement)
return this.raw(statement)
}

/**
Expand Down

0 comments on commit 0db2a23

Please sign in to comment.