Note that there are some explanatory texts on larger screens.

plurals
  1. POrails generate migration add_index_to... does not put the actual index in the migration file
    primarykey
    data
    text
    <p>I created a users table via "rails generate model User name:string email:string ..." the migration file was created as well.</p> <pre><code>class CreateUsers &lt; ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :email t.timestamps end end end </code></pre> <p>Now I want to add an index to the email column "following the tutorial" I've done this successfully the first time through using sqlite3. Second time through im using MySql (mysql2). Again created the table fine with generate model.. When I run the following:</p> <pre><code>rails generate migration add_index_to_users_email </code></pre> <p>the process ends with no error message and creates the migration file as shown below, but there is no setting of any index..</p> <pre><code>class AddIndexToUsersEmail &lt; ActiveRecord::Migration def change end end </code></pre> <p>Im expecting to see <code>add_index :users, :email, unique: true</code> in there ... Anybody have any idea's.. searched other threads to no avail.. running rails 4, mysql 5.6 ruby 1.9.3 my schema that was created after initil db:migrate is:</p> <pre><code>ActiveRecord::Schema.define(version: 20131024161033) do create_table "users", force: true do |t| t.string "name" t.string "email" t.string "city" t.string "state" t.string "zip" t.string "mobile_phone" t.string "mobile_phone_type" t.date "birth_date" t.string "user_type" t.string "ss_num" t.boolean "agree_to_terms" t.datetime "created_at" t.datetime "updated_at" end end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload