Skip to content

Commit

Permalink
Merge branch 'release-3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jun 26, 2016
2 parents 7b840dc + 4ae6988 commit 88ae4fd
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 54 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="3.0.1"></a>
## [3.0.1](https://github.com/adonisjs/adonis-lucid/compare/v3.0.0...v3.0.1) (2016-06-26)


### Bug Fixes

* **migrations:** return migrations class body instead of instance([358aeb6](https://github.com/adonisjs/adonis-lucid/commit/358aeb6))



<a name="3.0.0"></a>
# 3.0.0 (2016-06-26)

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"directories": {
"test": "test"
},
"version": "3.0.0",
"version": "3.0.1",
"scripts": {
"test": "npm run lint && node --harmony_proxies ./node_modules/.bin/_mocha test/unit test/acceptance",
"test": "npm run lint && node --harmony_proxies ./node_modules/.bin/istanbul cover _mocha --report lcovonly -- -R spec test/unit test/acceptance && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"lint": "standard src/**/*.js src/**/**/*.js src/**/**/**/*.js lib/*.js test/**/*.js providers/*.js",
"test:all": "DB=sqlite3 npm run test && DB=mysql npm run test && DB=pg npm run test",
"coverage": "node --harmony_proxies ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha test/unit",
Expand All @@ -26,6 +26,7 @@
"cz-conventional-changelog": "^1.1.5",
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "^1.2.0",
"mysql": "^2.10.2",
"pg": "^4.5.1",
"semantic-release": "^4.3.5",
Expand Down
7 changes: 3 additions & 4 deletions src/Commands/Refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ class Refresh extends Command {
try {
this.checkEnv(flags.force)
const migrationsFiles = this.loadFiles(this.helpers.migrationsPath())
yield this.migrations.down(migrationsFiles, 0)
const response = yield this.migrations.up(migrationsFiles)
const MigrationsRunner = this.migrations
yield new MigrationsRunner().down(migrationsFiles, 0)
const response = yield new MigrationsRunner().up(migrationsFiles)
const successMessage = 'Migrations successfully refreshed.'
const infoMessage = 'Already at the latest batch.'
this.log(response.status, successMessage, infoMessage)
} catch (e) {
this.error(e)
} finally {
this.migrations.database.close()
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/Commands/Reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ class Reset extends Command {
this.checkEnv(flags.force)

const migrationsFiles = this.loadFiles(this.helpers.migrationsPath())
const response = yield this.migrations.down(migrationsFiles, 0)
const MigrationsRunner = this.migrations
const response = yield new MigrationsRunner().down(migrationsFiles, 0)

const successMessage = 'Rolled back to latest batch.'
const infoMessage = 'Already at the latest batch.'
this.log(response.status, successMessage, infoMessage)
} catch (e) {
this.error(e)
} finally {
this.migrations.database.close()
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/Commands/Rollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ class Rollback extends Command {
this.checkEnv(flags.force)

const migrationsFiles = this.loadFiles(this.helpers.migrationsPath())
const response = yield this.migrations.down(migrationsFiles, flags.batch)
const MigrationsRunner = this.migrations
const response = yield new MigrationsRunner().down(migrationsFiles, flags.batch)

const successMessage = flags.batch ? `Rolled back to ${flags.batch} batch.` : 'Rolled back to previous batch.'
const infoMessage = 'Already at the latest batch.'
this.log(response.status, successMessage, infoMessage)
} catch (e) {
this.error(e)
} finally {
this.migrations.database.close()
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/Commands/Run.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ class Run extends Command {

const selectedFiles = flags.files ? flags.files.split(',') : null
const migrationsFiles = this.loadFiles(this.helpers.migrationsPath(), selectedFiles)

const response = yield this.migrations.up(migrationsFiles)
const MigrationsRunner = this.migrations
const response = yield new MigrationsRunner().up(migrationsFiles)

const successMessage = 'Database migrated successfully.'
const infoMessage = 'Nothing to migrate.'
this.log(response.status, successMessage, infoMessage)
} catch (e) {
this.error(e)
} finally {
this.migrations.database.close()
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Commands/Seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class Seed extends Command {
this.success(`${this.icon('success')} seeded database successfully`)
} catch (e) {
this.error(e)
} finally {
this.migrations.database.close()
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Commands/Status.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ class Status extends Command {
* @public
*/
* handle (options, flags) {
const MigrationsRunner = this.migrations
const migrationsRunner = new MigrationsRunner()
try {
const migrationsFiles = this.loadFiles(this.helpers.migrationsPath())
const response = yield this.migrations.status(migrationsFiles)
const response = yield migrationsRunner.status(migrationsFiles)
this.table(['Migration', 'Status'], response)
} catch (e) {
this.error(e)
} finally {
this.migrations.database.close()
migrationsRunner.database.close()
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions src/Migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ const mixin = require('es6-class-mixin')
const Lock = require('./Mixins/Lock')
const Migrate = require('./Mixins/Migrate')
const Batch = require('./Mixins/Batch')
let ConfigReference = null
let DatabaseReference = null

class Migrations {

constructor (Database, Config) {
this.database = Database
this.migrationsTable = Config.get('database.migrationsTable', 'adonis_schema')
constructor () {
this.database = DatabaseReference
this.migrationsTable = ConfigReference.get('database.migrationsTable', 'adonis_schema')
this.lockTable = `${this.migrationsTable}_lock`
this.migrations = []
}
Expand Down Expand Up @@ -168,4 +170,12 @@ class Migrations {

class ExtendedMigrations extends mixin(Migrations, Lock, Migrate, Batch) {}

module.exports = ExtendedMigrations
class MigrationsManager {
constructor (Database, Config) {
DatabaseReference = Database
ConfigReference = Config
return ExtendedMigrations
}
}

module.exports = MigrationsManager
4 changes: 2 additions & 2 deletions test/acceptance/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ setup.end = function * () {

setup.migrate = function * (schemas, direction) {
const Migrations = Ioc.use('Adonis/Src/Migrations')
yield Migrations[direction](schemas)
yield new Migrations()[direction](schemas)
if (direction === 'down') {
yield Migrations.database.schema.dropTable('adonis_migrations')
yield new Migrations().database.schema.dropTable('adonis_migrations')
}
}

Expand Down
Loading

0 comments on commit 88ae4fd

Please sign in to comment.