mysql - Knex.js migrations with unique constraint function -




i trying migrate new table database. table users table. here code have:

exports.up = function(knex, promise) {   return knex.schema.createtableifnotexists('users', function(table) {     table.increments('id').primary();     table.string('first_name').notnullable();     table.string('last_name').notnullable();     table.string('email').unique().notnullable();     table.string('password').notnullable();     table.timestamps(false, true);   }).then(() => {     console.log('users table created!');   }) };  exports.down = function(knex, promies) {   return knex.schema.droptable('users')     .then(() => {       console.log('users table has been dropped!');     }) }; 

this returns 2 errors:

knex:warning - migrations failed error: alter tableusersadd uniqueusers_email_unique(email) - key column 'email' doesn't exist in table

error: key column 'email' doesn't exist in table

it appears unique() trying preform alter table on table i'm trying create. error email column doesn't exist. doing wrong here or can not perform unique() function on column when creating table? saw examples of using unique() function in createtable on docs. i'm @ loss why respond said error.

my database getting created , can see it. appears unique() constraint doesn't applied email column not created either.

so turns out need drop tables , re-run migration. why wasn't working , why think trying perform alter table.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -