Every repository with this icon (
Every repository with this icon (
tree 25804442e5baaf955eea73c8135b4d2f2f4dca00
parent 09363322235d68e723d30d433352c09492780ed9
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Wed Jun 25 14:51:33 -0700 2008 | [reagent] |
| |
CHANGELOG | Thu Aug 09 08:27:15 -0700 2007 | [cnixon] |
| |
History.txt | Mon Jul 14 20:21:28 -0700 2008 | [crnixon] |
| |
Manifest.txt | Mon Jul 14 20:21:28 -0700 2008 | [crnixon] |
| |
README.rdoc | Tue Jul 15 12:34:12 -0700 2008 | [crnixon] |
| |
Rakefile | Mon Jul 14 20:21:28 -0700 2008 | [crnixon] |
| |
init.rb | Thu Aug 09 08:27:15 -0700 2007 | [cnixon] |
| |
integration_tests/ | Fri Feb 08 13:48:32 -0800 2008 | [cnixon] |
| |
lib/ | Tue Jul 15 12:27:50 -0700 2008 | [crnixon] |
| |
setup.rb | Thu Aug 09 08:25:57 -0700 2007 | [cnixon] |
| |
tasks/ | Mon Jul 14 20:21:28 -0700 2008 | [crnixon] |
| |
test/ | Tue Jul 15 12:27:50 -0700 2008 | [crnixon] |
foreign_key_migrations plugin for ActiveRecord
by Clinton R. Nixon of Viget Labs
URL: http://github.com/crnixon/foreign_key_migrations
DESCRIPTION:
Allows foreign keys to be specified in ActiveRecord migrations. Foreign keys via this plugin are currently supported for the following database adapters:
- MySQL
- PostgreSQL
- SQLite
- SQLite3
Foreign keys can be specified in four ways, modeled on indexes and current ActiveRecord migration syntax.
- In a column definition:
class AddUsersTable < ActiveRecord::Migration def self.up create_table :users do |t| t.column :department_id, :integer, :references => :departments end end end - In a column definition, using references or belongs_to:
class AddUsersTable < ActiveRecord::Migration def self.up create_table :users do |t| t.references :department # t.belongs_to :department also works end end end - In a table definition:
class AddUsersTable < ActiveRecord::Migration def self.up create_table :users do |t| t.column :department_id, :integer t.foreign_key :on => :department_id, :references => :departments end end end - Or outside a table definition:
class AddUsersTable < ActiveRecord::Migration def self.up create_table :users do |t| t.column :department_id, :integer end add_foreign_key :on => :users, :references => :departments end end
Foreign keys can be more complex to deal with non-Rails or legacy databases, such as:
add_foreign_key
:on => {:table => :users, :column => :dept_id},
:references => {:table => :departments, :column => :dept_id}
FEATURES/PROBLEMS:
- No integration tests for SQLite or PostgreSQL.
REQUIREMENTS:
- To run the tests, you need the Shoulda, spect, and mocha gems.
- ActiveRecord
LICENSE:
(ISC License)
Copyright © 2008 Clinton R. Nixon of Viget Labs
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.




