Skip to content

Instantly share code, notes, and snippets.

@3014zhangshuo
Created January 15, 2019 08:14
Show Gist options
  • Save 3014zhangshuo/c87b2bf74cf0765f3a80918805d5ba3f to your computer and use it in GitHub Desktop.
Save 3014zhangshuo/c87b2bf74cf0765f3a80918805d5ba3f to your computer and use it in GitHub Desktop.
Rails error unkown primary key for table but the id exist
class AddPrimaryKeyToCollections < ActiveRecord::Migration
def change
execute "ALTER TABLE collections ADD PRIMARY KEY (id);"
end
end
# https://stackoverflow.com/questions/18056162/getting-unknown-primary-key-for-table-while-the-id-is-there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment