Is there some standard way to test migrations? It seems to me that an additional safeguard for migrations would be to test and see if applying the migrations to the test database allows one to reconstruct the structure of the development database. If you can''t, then there is an error in your migrations, most likely because someone hand-modified the database without generating a migration for it. The biggest problem with writing unit tests for this is that (AFAIK) there is no simple way to apply migrations to the test database instead of the development one. Is there a simple switch or something in rake that will make it use the test database? _Kevin -- Posted with http://DevLists.com. Sign up and save your time!
rake migrate RAILS_ENV=test Duane Johnson (canadaduane) http://blog.inquirylabs.com/ On Mar 9, 2006, at 9:42 AM, Kevin Olbrich wrote:> Is there some standard way to test migrations? > > It seems to me that an additional safeguard for migrations would be to > test and see if applying the migrations to the test database allows > one > to reconstruct the structure of the development database. > > If you can''t, then there is an error in your migrations, most likely > because someone hand-modified the database without generating a > migration for it. > > The biggest problem with writing unit tests for this is that (AFAIK) > there is no simple way to apply migrations to the test database > instead > of the development one. > > Is there a simple switch or something in rake that will make it use > the > test database? > > _Kevin > > -- > Posted with http://DevLists.com. Sign up and save your time! > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Somehow that makes perfect sense! Thanks! _Kevin On Thursday, March 09, 2006, at 10:06 AM, Duane Johnson wrote:>rake migrate RAILS_ENV=test > >Duane Johnson >(canadaduane) >http://blog.inquirylabs.com/ > > >On Mar 9, 2006, at 9:42 AM, Kevin Olbrich wrote: > >> Is there some standard way to test migrations? >> >> It seems to me that an additional safeguard for migrations would be to >> test and see if applying the migrations to the test database allows > one >> to reconstruct the structure of the development database. >> >> If you can''t, then there is an error in your migrations, most likely >> because someone hand-modified the database without generating a >> migration for it. >> >> The biggest problem with writing unit tests for this is that (AFAIK) >> there is no simple way to apply migrations to the test database > instead >> of the development one. >> >> Is there a simple switch or something in rake that will make it use > the >> test database? >> >> _Kevin >> >> -- >> Posted with http://DevLists.com. Sign up and save your time! >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-- Posted with http://DevLists.com. Sign up and save your time!
On 9 Mar 2006 16:42:40 -0000, Kevin Olbrich <devlists-rubyonrails@devlists.com> wrote:> Is there some standard way to test migrations? > > It seems to me that an additional safeguard for migrations would be to > test and see if applying the migrations to the test database allows one > to reconstruct the structure of the development database. > > If you can''t, then there is an error in your migrations, most likely > because someone hand-modified the database without generating a > migration for it. > > The biggest problem with writing unit tests for this is that (AFAIK) > there is no simple way to apply migrations to the test database instead > of the development one. > > Is there a simple switch or something in rake that will make it use the > test database?I have a script that: - removes the development and test database - creates the development and test database - performs the migrations on the development database - loads my test fixtures into the development database - and runs all unit and functional tests So, if there''s a mistake in the migrations, it shows up when the script runs (i.e. migration fails or the tests fail). And it''s easy to fix the problem and do it again.
On Mar 9, 2006, at 9:27 AM, Joe Van Dyk wrote:>> The biggest problem with writing unit tests for this is that (AFAIK) >> there is no simple way to apply migrations to the test database >> instead >> of the development one. >> >> Is there a simple switch or something in rake that will make it >> use the >> test database? > > I have a script that: > > - removes the development and test database > - creates the development and test database > - performs the migrations on the development database > - loads my test fixtures into the development database > - and runs all unit and functional tests+1 -- -- Tom Mornini