I've created the following transaction:
exports.up = async (knex, Promise) => (await knex.schema.hasTable('settings'))
? null
: knex.schema.createTable('settings', function (table) {
table.increments('id')
table.string('name').notNullable().unique()
table.string('value').notNullable()
table.primary('name')
}).then(() => {
return knex('settings').insert([
{ name: 'sandbox', value: 'off'},
{ name: 'promo', value: 'off'}
]);
});
exports.down = async (knex, Promise) => (await knex.schema.hasTable('settings'))
? knex.schema.dropTable('settings')
: null
essentially I'm trying to create a settings
table which define two primary keys, an id
and a name
. The problem is that I get this error:
migration failed with error: alter table
settings
add uniquesettings_name_unique
(name
) - Specified key was too long; max key length is 767 bytes
how can I fix?