We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I am using knex for my project.
exports.up = function(knex, Promise) { return knex.schema.createTable('users', function (t) { t.increments(); // Database authenticatable t.string('email').notNullable().unique().index(); t.string('encrypted_password').notNullable(); // Recoverable t.string('reset_password_token').unique().index(); t.dateTime('reset_password_sent_at'); // Rememberable t.dateTime('remember_created_at'); // Trackable t.integer('sign_in_count').notNullable().defaultTo(0); t.dateTime('current_sign_in_at'); t.dateTime('last_sign_in_at'); t.specificType('current_sign_in_ip', 'inet'); t.specificType('last_sign_in_ip', 'inet'); // Confirmable // t.string('confirmation_token').unique().index(); // t.dateTime('confirmed_at'); // t.dateTime('confirmation_sent_at'); // t.string('unconfirmed_email'); // Only if using reconfirmable // Lockable // t.integer('failed_attempts').defaultTo(0).notNullable(); // Only if lock strategy is 'failed_attempts' // t.string('unlock_token').unique().index(); // Only if unlock strategy is 'email' or 'both' // t.dateTime('locked_at') t.timestamps(); }); };
This migration creates total of 5 indexes. Indexes: "users_pkey" PRIMARY KEY, btree (id) "users_email_unique" UNIQUE CONSTRAINT, btree (email) "users_reset_password_token_unique" UNIQUE CONSTRAINT, btree (reset_password_token) "users_email_index" btree (email) "users_reset_password_token_index" btree (reset_password_token)
The text was updated successfully, but these errors were encountered:
console.log( knex.schema.createTable("x",function(table){ table.string("name").unique().index(); }) .toString());
Result: create table "x" ("name" varchar(255)); create unique index x_name_unique on "x" ("name"); create index x_name_index on "x" ("name")
Forget turn off the regular index?
Sorry, something went wrong.
oh,I realize that unique() create unique index automatically.
unique()
console.log( knex.schema.createTable("x",function(table){ table.string("name").unique(); }) .toString());
Result: create table "x" ("name" varchar(255)); create unique index x_name_unique on "x" ("name")
No branches or pull requests
Hi,
I am using knex for my project.
This migration creates total of 5 indexes.
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
"users_email_unique" UNIQUE CONSTRAINT, btree (email)
"users_reset_password_token_unique" UNIQUE CONSTRAINT, btree (reset_password_token)
"users_email_index" btree (email)
"users_reset_password_token_index" btree (reset_password_token)
The text was updated successfully, but these errors were encountered: