<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-11933937.post744880096818773440..comments</id><updated>2008-03-29T17:34:34.055-05:00</updated><category term='pattern'/><category term='.net'/><category term='agile'/><category term='mysql'/><category term='ruby/rails'/><category term='humor'/><category term='efficiency'/><title type='text'>Comments on STEPHEN CHU . com: Why create database migrations, when you don't nee...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.stephenchu.com/feeds/744880096818773440/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default'/><link rel='alternate' type='text/html' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html'/><author><name>Stephen Chu</name><uri>http://www.blogger.com/profile/07181510921622947661</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-11933937.post-8532030023731651367</id><published>2008-03-29T17:34:00.000-05:00</published><updated>2008-03-29T17:34:00.000-05:00</updated><title type='text'>Actually, I ended up figuring it out. Turns out th...</title><content type='html'>Actually, I ended up figuring it out. Turns out the testing framework of Rails includes a class to handle testing file uploads. So I just grab that and I'm good to go! It's quite cool as I can keep images in a reference_data/images directory and then do stuff like this:&lt;BR/&gt;&lt;BR/&gt;&lt;B&gt;&lt;BR/&gt;require 'action_controller/test_process'&lt;BR/&gt;&lt;BR/&gt;Logo.create! :uploaded_data =&gt; ActionController::TestUploadedFile.new(&lt;BR/&gt;'test/reference_data/images/logo.jpg', &lt;BR/&gt;'image/jpg')&lt;BR/&gt;&lt;/B&gt;&lt;BR/&gt;&lt;BR/&gt;So now I can load images through attachment_fu and it does all the resizing, thumbnailing, directory creation and such.&lt;BR/&gt;&lt;BR/&gt;I ended up creating a custom rake task to delete the images store (the attachment_fu processed images, not the ones in reference_data!), wipe the DB, recreate it, run the migrations and load my data (via your idea).&lt;BR/&gt;&lt;BR/&gt;So voila! single command and I'm ready to go!&lt;BR/&gt;&lt;BR/&gt;Thanks a million!&lt;BR/&gt;&lt;BR/&gt;-Dan</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/8532030023731651367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/8532030023731651367'/><link rel='alternate' type='text/html' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html?showComment=1206830040000#c8532030023731651367' title=''/><author><name>Danimal</name><uri>http://www.blogger.com/profile/11574843756882461141</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html' ref='tag:blogger.com,1999:blog-11933937.post-744880096818773440' source='http://www.blogger.com/feeds/11933937/posts/default/744880096818773440' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-481557247'/></entry><entry><id>tag:blogger.com,1999:blog-11933937.post-256480225742295992</id><published>2008-03-29T14:07:00.000-05:00</published><updated>2008-03-29T14:07:00.000-05:00</updated><title type='text'>Stephen,&lt;br&gt;&lt;br&gt;I love this idea but I'm wondering...</title><content type='html'>Stephen,&lt;BR/&gt;&lt;BR/&gt;I love this idea but I'm wondering how you'd handle prepopulating binary data? I.e. I use attachment_fu for logos for some models. I can see having a "reference_images" directory to hold the source files for the logos. But I don't know how to simulate the data read that happens from a form using a file_field&lt;BR/&gt;&lt;BR/&gt;Thoughts?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/256480225742295992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/256480225742295992'/><link rel='alternate' type='text/html' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html?showComment=1206817620000#c256480225742295992' title=''/><author><name>Danimal</name><uri>http://www.blogger.com/profile/11574843756882461141</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html' ref='tag:blogger.com,1999:blog-11933937.post-744880096818773440' source='http://www.blogger.com/feeds/11933937/posts/default/744880096818773440' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-481557247'/></entry><entry><id>tag:blogger.com,1999:blog-11933937.post-4650285493037191460</id><published>2007-12-21T03:02:00.000-06:00</published><updated>2007-12-21T03:02:00.000-06:00</updated><title type='text'>Hello,&lt;br&gt;&lt;br&gt;I'm quite new in Ruby so I don't kno...</title><content type='html'>Hello,&lt;BR/&gt;&lt;BR/&gt;I'm quite new in Ruby so I don't know that much about it. &lt;BR/&gt;What you describe is very useful for me but I need more details. From your example it seems that you only get the data from a table imported and exported into the new structure of the database, is this correct?&lt;BR/&gt;Is it possible to have more examples and tutorials on Rubby??&lt;BR/&gt;&lt;BR/&gt;Regards,&lt;BR/&gt;Pedro&lt;BR/&gt;pedro_garrinhas@hotmail.com</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/4650285493037191460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/4650285493037191460'/><link rel='alternate' type='text/html' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html?showComment=1198227720000#c4650285493037191460' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html' ref='tag:blogger.com,1999:blog-11933937.post-744880096818773440' source='http://www.blogger.com/feeds/11933937/posts/default/744880096818773440' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1490992972'/></entry><entry><id>tag:blogger.com,1999:blog-11933937.post-6098064276237554008</id><published>2007-12-18T00:24:00.000-06:00</published><updated>2007-12-18T00:24:00.000-06:00</updated><title type='text'>Curtis:&lt;br&gt;&lt;br&gt;First, thank you for sharing your t...</title><content type='html'>Curtis:&lt;BR/&gt;&lt;BR/&gt;First, thank you for sharing your thoughts. I love it when I get honest feedback :-)&lt;BR/&gt;&lt;BR/&gt;Just to clarify, the strategy above is deduced from experiences of a 16-developer Rails project. It works out quite well for us.&lt;BR/&gt;&lt;BR/&gt;Both &lt;B&gt;reference data&lt;/B&gt; and &lt;B&gt;user data&lt;/B&gt; that I mentioned above are all data &lt;I&gt;required&lt;/I&gt; for the application to go into production. If, while developing a feature, you have &lt;I&gt;temporary&lt;/I&gt; data that you are unwilling to blow away, one can solve this problem by having a third set of data (perhaps called &lt;I&gt;development data&lt;/I&gt;) and be loaded in your &lt;I&gt;data:load&lt;/I&gt; after &lt;I&gt;:reference_data&lt;/I&gt; and &lt;I&gt;:user_data&lt;/I&gt;. My advise is, script them. It shouldn't be too hard to script such data, or it indicates to me the model/controller is hairy and needs some refactoring love. After you are done with your feature, your development data hopefully either becomes legit reference data or user data, or becomes part of another dataset's (like QA/Testing) reference data or user data. I would still advise such data to be part of one of your development datasets. The fact that you can selectively load any datasets for any environments by not using migrations gives you a lot more control over your data on what gets loaded and what doesn't.&lt;BR/&gt;&lt;BR/&gt;Don't hate blowing away your database during development. Because, it happens, and I do it on every check-in. The point is, find ways to re-generate all your data using ActiveRecord models, and keep all data valid *at all times*. If you have data in your database you cannot generate through AR models because it violates validations, you will want to blow away your database.&lt;BR/&gt;&lt;BR/&gt;Collapsing migrations is a good and efficient way to reduce the number of migrations. But IMHO I don't need to use this trick yet when I don't even need migrations.&lt;BR/&gt;&lt;BR/&gt;Once your application goes into production, not just database migrations but the whole development becomes quite a different ball game. Release 2.0, bug fixes, app monitoring, testing, branching, etc., all become important at a different level. But, since you need them all once you go into production, does it make sense to do them all in pre-release 1.0 just to get some training? From 1.0 and on, &lt;I&gt;'planning'&lt;/I&gt; becomes the name of the game before your every move.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/6098064276237554008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/6098064276237554008'/><link rel='alternate' type='text/html' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html?showComment=1197959040000#c6098064276237554008' title=''/><author><name>Stephen Chu</name><uri>http://www.blogger.com/profile/07181510921622947661</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html' ref='tag:blogger.com,1999:blog-11933937.post-744880096818773440' source='http://www.blogger.com/feeds/11933937/posts/default/744880096818773440' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-3841993'/></entry><entry><id>tag:blogger.com,1999:blog-11933937.post-2921443326910793573</id><published>2007-12-17T11:43:00.000-06:00</published><updated>2007-12-17T11:43:00.000-06:00</updated><title type='text'>Stephen,&lt;br&gt;&lt;br&gt;I personally have found it a joy t...</title><content type='html'>Stephen,&lt;BR/&gt;&lt;BR/&gt;I personally have found it a joy to use migrations during development for teams larger than one.  As soon as you have more than one developer, you have the potential to step on each other's toes.&lt;BR/&gt;&lt;BR/&gt;If I'm working on a feature, putting in and taking out data as I develop, I hate having to blow away my database when developer #2 adds a column to a table.  This data may not be reference data or even required--it's just data that I'm working with at that very moment, and I want it to stick around until I'm finished with it.&lt;BR/&gt;&lt;BR/&gt;If migrations get big and messy, then we'll collapse and clean them up before we roll to production, but I still like having them during development.  And, shoot, if we're going to use migrations as soon as we roll to production, we might as well train ourselves well with them during development.&lt;BR/&gt;&lt;BR/&gt;Having the reference data as a rake task is a cool idea, though.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/2921443326910793573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11933937/744880096818773440/comments/default/2921443326910793573'/><link rel='alternate' type='text/html' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html?showComment=1197913380000#c2921443326910793573' title=''/><author><name>Curtis Summers</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.stephenchu.com/2007/12/why-create-database-migrations-when-you.html' ref='tag:blogger.com,1999:blog-11933937.post-744880096818773440' source='http://www.blogger.com/feeds/11933937/posts/default/744880096818773440' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1845169818'/></entry></feed>
