1

I have tried several ways to add string as a primary key in rails. So far, this is what I have tried. Can someone please help find the solution.

class CreateClients < ActiveRecord::Migration
  def change
    create_table :clients, primary_key: :client_id, id: false do |t|
      t.string :client_id
      t.string :client_secret
      t.integer :app_id
    end
    add_index :clients, [:app_id, :client_id]
  end
end

--

class CreateClients < ActiveRecord::Migration
  def change
    create_table :clients, id: false do |t|
      t.string :client_id, primary: true
      t.string :client_secret
      t.integer :app_id
    end
    add_index :clients, [:app_id, :client_id]
  end
end

--

class CreateClients < ActiveRecord::Migration
  def change
    create_table :clients, id: false do |t|
      t.string :client_id, primary_key: true
      t.string :client_secret
      t.integer :app_id
    end
    add_index :clients, [:app_id, :client_id]
  end
end
tereško
  • 58,060
  • 25
  • 98
  • 150
Jason Waldrip
  • 5,038
  • 8
  • 36
  • 59

0 Answers0