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
  • 57,247
  • 24
  • 95
  • 149
Jason Waldrip
  • 4,919
  • 8
  • 35
  • 58

0 Answers0