Home > Software design >  Where is the index on this table
Where is the index on this table

Time:10-06

Guys I came across an online practice question, and there's something that I don't properly understand

Below is a migration file

class ContactsMigration < ActiveRecord::Migration
  def change
    create_table :contacts do |t|
      t.string :name
      t.integer :telephone_number
      t.text :address, null: false
      t.timestamps
    end
  end
end

One of the questions is asking if there are any indexes on this table, and the correct answer is yes. Can't figure out where is the index here though. The logical is the timestamp, but the guides don't show that those columns are automatically indexed. Where am I going wrong? Any help or a link to a guide would be extremely appreciated

CodePudding user response:

Active Record Basics

Primary keys - By default, Active Record will use an integer column named id as the table's primary key (bigint for PostgreSQL and MySQL, integer for SQLite). When using Active Record Migrations to create your tables, this column will be automatically created.

  • Related