Wappler Version : 3.7.2
Operating System : mac
Server Model: node
Database Type: maria
Hosting Type: custom
Expected behavior
I should be able to rename the primary key field of a table.
Actual behavior
An error is generated
How to reproduce
Attempt to rename an Increment field
When starting here:
And renaming id to user_id
The following error is triggered:
1 Like
George
3
Could you check the generated code what is exactly wrong?
Is it the drop column?
You can just edit the code and in the editor and just reapply the change to run it again.
This will help me solve the problem faster 
For the syntax and better understanding of the generated changes code, you can check the Knex js reference at http://knexjs.org/
Here’s the code generated
exports.up = function(knex) {
return knex.schema
.table('users', function (table) {
table.renameColumn('id', 'user_id');
table.dropPrimary();
table.increments('user_id');
})
};
exports.down = function(knex) {
return knex.schema
.table('users', function (table) {
table.renameColumn('user_id', 'id');
table.increments('id').primary().alter();
})
};
Teodor
6
This has been fixed in Wappler 3.7.4
Teodor
Closed
8
This topic was automatically closed after 46 hours. New replies are no longer allowed.