Adding/updating fields

Hi,

I’m trying to apply database changes, but I got this message. How can I make the proper changes to save everything?

Screenshot_333

Fields I’m using:

Screenshot_335

Here’s the code for it as well:

exports.up = function(knex) {
  return knex.schema
.table('users', function (table) {
  table.renameColumn('id', 'user_id');
  table.dropPrimary();
  table.increments('user_id');
  table.string('pass_hash', 255);
  table.string('pass_salt', 15);
  table.string('role', 25);
  table.datetime('most_recent_login');
  table.string('email', 254).alter();
})
};

exports.down = function(knex) {
  return knex.schema
.table('users', function (table) {
  table.renameColumn('user_id', 'id');
  table.increments('id').primary().alter();
  table.dropColumn('pass_hash');
  table.dropColumn('pass_salt');
  table.dropColumn('role');
  table.dropColumn('most_recent_login');
  table.string('email', 50).alter();
})
};

I don’t believe the Database designer properly handles the renaming of an incrementing field, so you will probably have to do that part of your changes in another database tool.

Thanks Ken! Fixed it now, but which database tools would I be able to change it in?

Everybody has their favorite…I use DataGrip.

Others include phpMyAdmin, Navicat, Sequel Pro

1 Like

Not sure exactly what is going wrong here.
If it is the rename of your primary key or type change.

@mebeingken if you can isolate the cases that go wrong, we can fix them.

I was under tge imply that only type change if the primary key goes wrong.

But the more exact cases we have the faster we can fix them.

1 Like

Yep it was the renaming of the primary key

Just added

2 Likes