0

I have some raw sql statements that create triggers and functions in my migrations. They are not invoked in the tests.

How can I use normal migrations to setup the test database? And why isn't that the default method?

snøreven
  • 1,904
  • 2
  • 19
  • 39

1 Answers1

0

Reason is that the test database is restored from schema.rb file. And Schema dump doesnt create procedures,functions, fkeys etc. The reason for that is Rails doesnt encourage using them. You can however change the schema dump format to sql.

config.active_record.schema_format = :sql

See following thread Why does rake db:migrate in Rails not add functions to the schema file?

Check this article as well http://pivotallabs.com/users/jdean/blog/articles/1707-using-mysql-foreign-keys-procedures-and-triggers-with-rails

Community
  • 1
  • 1
irfn
  • 560
  • 3
  • 11