mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
8768305f20
The name of the foreign key is not relevant from a users perspective. Using random names resolves the urge to rename the foreign key when the respective table or column is renamed.
22 lines
532 B
Ruby
22 lines
532 B
Ruby
ActiveRecord::Schema.define do
|
|
create_table :table_with_autoincrement, :force => true do |t|
|
|
t.column :name, :string
|
|
end
|
|
|
|
execute "DROP TABLE fk_test_has_fk" rescue nil
|
|
execute "DROP TABLE fk_test_has_pk" rescue nil
|
|
execute <<_SQL
|
|
CREATE TABLE 'fk_test_has_pk' (
|
|
'pk_id' INTEGER NOT NULL PRIMARY KEY
|
|
);
|
|
_SQL
|
|
|
|
execute <<_SQL
|
|
CREATE TABLE 'fk_test_has_fk' (
|
|
'id' INTEGER NOT NULL PRIMARY KEY,
|
|
'fk_id' INTEGER NOT NULL,
|
|
|
|
FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('pk_id')
|
|
);
|
|
_SQL
|
|
end
|