LoginSignup
0
0

More than 5 years have passed since last update.

ActiveRecord migrationのPRIMARYKEY名の変更

Posted at
hoge.rb
class Hoge < ActiveRecord::Migration
  def up
    create_table(:fuga, primary_key: 'hoge_id') do |d|
      d.timestamps
    end
  end
end

これで、PRIMARY KEY & auto-incrementの設定がされた"id"以外の名前のcolumnができる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0