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

Cannot changeColumn with primary key using MySQL #59

Closed
rjkip opened this issue Dec 17, 2012 · 1 comment
Closed

Cannot changeColumn with primary key using MySQL #59

rjkip opened this issue Dec 17, 2012 · 1 comment

Comments

@rjkip
Copy link

rjkip commented Dec 17, 2012

When I try to MysqlDriver#changeColumn(), no options are passed to MysqlDriver#createColumnDef() and #createColumnConstraint(). These options are used when changing a primary key. The migration stops here:

if (spec.primaryKey && options.emitPrimaryKey) {
  constraint.push('PRIMARY KEY');

What are these options and what is emitPrimaryKey?

Migration

var dbm = require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
    db.changeColumn(
        "users",
        "id",
        {
            type: type.INTEGER,
            primaryKey: true,
            autoIncrement: true
        },
        callback
    );
};

exports.down = function(db, callback) {
    db.changeColumn(
        "users",
        "id",
        {
            type: type.INTEGER,
            primaryKey: true
        },
        callback
    );
};
@kunklejr
Copy link
Contributor

The available column spec options are documented in the README as a subsection to createTable (https://github.com/nearinfinity/node-db-migrate#createtabletablename-columnspec-callback).

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

2 participants