Skip to content

Instantly share code, notes, and snippets.

@obfuscurity
Created November 30, 2011 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obfuscurity/1409167 to your computer and use it in GitHub Desktop.
Save obfuscurity/1409167 to your computer and use it in GitHub Desktop.
002_AddForeignKeys.rb for blog post
# migrations/002_AddForeignKeys.rb
Sequel.migration do
up do
alter_table(:accounts) do
add_foreign_key(:owner_id, :users)
end
end
down do
alter_table(:accounts) do
drop_constraint(:accounts_owner_id_fkey)
drop_column(:owner_id)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment