Answers for "rails unique index"

0

create table index unique rails

class CreateFoobars < ActiveRecord::Migration
  def change
    create_table :foobars do |t|
      t.string :name, index: {unique: true}
    end
  end
end
Posted by: Guest on August-21-2021
0

create table index unique rails

class CreateFoos < ActiveRecord::Migration
  def change
    create_table :foos do |t|
      t.string :bar, :null => false

      t.index :bar, unique: true
    end
  end
end
Posted by: Guest on August-21-2021

Browse Popular Code Answers by Language