Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.raw in migrations doesn't work #67

Closed
nrempel opened this issue Oct 27, 2016 · 3 comments
Closed

this.raw in migrations doesn't work #67

nrempel opened this issue Oct 27, 2016 · 3 comments

Comments

@nrempel
Copy link

nrempel commented Oct 27, 2016

I'm trying to use this.raw in migrations to alter existing columns since knex doesn't support this yet: knex/knex#46, knex/knex#1759

When I try to execute the following command:

this.raw('alter table users alter column company_id set not null;');

I get the following error:

error: alter table users alter column company_id set not null; - bind message supplies 1 parameters, but prepared statement "" requires 0

Turning on the debug flag shows the following:

[ { method: 'raw',
    sql: 'alter table users alter column company_id set not null;',
    bindings: [ 'function (table) {\n    self._decorateTable(table)\n    callback(table)\n  }' ],
    options: {},
    __knexQueryUid: 'f6d51eb0-59b0-453a-b77a-9eff6a2d5612' } ]

Trying to follow the docs, I tried:

this.raw('alter column company_id set not null;').table('users');

And received this error: TypeError: Cannot read property 'table' of undefined

Any help would be appreciated.

Thanks!

@elhigu
Copy link

elhigu commented Oct 28, 2016

<any-help>Do you have more complete example somewhere. Your code does not show, where this is coming from. In knex you would usually use knex.raw or knex.schema.raw... Anyways I don't know anything about adonis-lucid so this might not be helpful at all :)</any-help>

@nrempel
Copy link
Author

nrempel commented Oct 28, 2016

Thanks @elhigu! I've looked into this a bit and it's not and issue with knex at all.

Actually, it turns out updating adonis-lucid to 3.0.9 fixes the problem.

All good!

@hendra1
Copy link

hendra1 commented Jun 22, 2020

on your schema, you can try this one:
this.db.raw('your raw command')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants