Hi Greg,
Here's a simple mysql-specific example for adding cascade delete
constraint, for authors----0..*books, that should give you an idea of
what to do in your oracle proj (using oracle-specific constraints):
# in config/environment.rb:
...
config.active_record.schema_format = :sql
...
# in db/migrate/002_create_books.rb
class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.integer :author_id, :null=>false
...
end
add_index :books, :author_id
...
#NOTE: mysql-specific fk-constraints.
execute "alter table books add constraint fk_book_author foreign
key (author_id) references authors(id) on delete cascade"
end
...
end
Then, after migrating, that constraint should show up in db/
development_structure.sql, which your tests will then use when re-
creating test db:
...
CREATE TABLE `books` (
...
CONSTRAINT `fk_book_author` FOREIGN KEY (`author_id`) REFERENCES
`authors` (`id`) ON DELETE CASCADE
...
Jeff
On Feb 18, 11:20 am, Greg Donald <[email protected]> wrote:
> What is everyone doing with regards to database constraints not being
> created in schema.rb ? I'm using Oracle and I just noticed none of
> the constraints I am creating in my migrations appear in my test
> schema. This makes me question the value of my test suite since I'm
> not running it on the same db constraints that will be present in
> production.
>
> I tried setting
>
> config.active_record.schema_format = :sql
>
> as suggested in a DHH post I found Googling, but the SQL file doesn't
> contain anymore than the schema.rb contains, it's just in a different
> format is all.
>
> Thanks,
>
> --
> Greg Donaldhttp://destiney.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---