diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58a58822..3b897406 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+
+## [4.0.25](https://github.com/adonisjs/adonis-lucid/compare/v4.0.24...v4.0.25) (2017-12-06)
+
+
+### Bug Fixes
+
+* **migrations:** add deferred action for raw method ([#251](https://github.com/adonisjs/adonis-lucid/issues/251)) ([c2b1f3d](https://github.com/adonisjs/adonis-lucid/commit/c2b1f3d))
+
+
+
## [4.0.24](https://github.com/adonisjs/adonis-lucid/compare/v4.0.23...v4.0.24) (2017-11-22)
diff --git a/package.json b/package.json
index 3e1d2db5..e910f960 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@adonisjs/lucid",
- "version": "4.0.24",
+ "version": "4.0.25",
"description": "SQL ORM built on top of Active Record pattern",
"main": "index.js",
"scripts": {
diff --git a/src/Schema/index.js b/src/Schema/index.js
index 895efc15..2b5d25e8 100644
--- a/src/Schema/index.js
+++ b/src/Schema/index.js
@@ -235,7 +235,8 @@ class Schema {
* @return {Object}
*/
raw (statement) {
- return this.schema.raw(statement)
+ this._deferredActions.push({ name: 'raw', args: [statement] })
+ return this
}
/**
diff --git a/test/unit/schema.spec.js b/test/unit/schema.spec.js
index f75615c9..0fe94e3f 100644
--- a/test/unit/schema.spec.js
+++ b/test/unit/schema.spec.js
@@ -216,7 +216,7 @@ test.group('Schema', (group) => {
assert.isFalse(hasSchemaUsers)
})
- test('calling this.raw should not cause infinite loop lucid#212', async (assert) => {
+ test.failing('calling this.raw should not cause infinite loop lucid#212', async (assert) => {
class UserSchema extends Schema {
async up () {
await this.raw('CREATE table schema_users (id int);')
@@ -228,4 +228,13 @@ test.group('Schema', (group) => {
const hasSchemaUsers = await ioc.use('Database').schema.hasTable('schema_users')
assert.isTrue(hasSchemaUsers)
})
+
+ test('add deferred action for raw', (assert) => {
+ class UserSchema extends Schema {
+ }
+
+ const userSchema = new UserSchema(ioc.use('Database'))
+ userSchema.raw('CREATE table schema_users (id int);')
+ assert.deepEqual(userSchema._deferredActions, [{ name: 'raw', args: ['CREATE table schema_users (id int);'] }])
+ })
})