<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ivan Enviroman &#187; sake</title>
	<atom:link href="http://www.ivanenviroman.com/tag/sake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ivanenviroman.com</link>
	<description>Sustainability, Business, Technology, and Spirit</description>
	<lastBuildDate>Sat, 04 Sep 2010 03:05:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rake Tasks for dumping mysql</title>
		<link>http://www.ivanenviroman.com/rake-tasks-for-dumping-mysql/</link>
		<comments>http://www.ivanenviroman.com/rake-tasks-for-dumping-mysql/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 15:50:10 +0000</pubDate>
		<dc:creator>Ivan Storck</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[sake]]></category>

		<guid isPermaLink="false">http://www.ivanenviroman.com/2008/02/20/rake-tasks-for-dumping-mysql/</guid>
		<description><![CDATA[I have definitely used sqlite database files but I also like sticking to mysql, because I know that&#8217;s what I&#8217;ll use on the the server. I&#8217;ve created some rake tasks to help me in this process. As usual, they go &#8230; <a href="http://www.ivanenviroman.com/rake-tasks-for-dumping-mysql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have definitely used <a href="http://solutions.treypiepmeier.com/2006/10/22/using-sqlite-with-rails/">sqlite</a> database files but I also like sticking to <a href="http://hivelogic.com/articles/installing-mysql-on-mac-os-x/">mysql</a>, because I know that&#8217;s what I&#8217;ll use on the the server. I&#8217;ve created some rake tasks to help me in this process. As usual, they go in <code>lib/tasks</code>.</p>
<p>here&#8217;s my <code>db.rake</code> file:</p>
<pre>
<code>
# with thanks to sake
# http://errtheblog.com/posts/60-sake-bomb
namespace :db do

  # command line usage: rake db:version
  desc "Returns the current schema version"
  task :version =&gt; :environment do
    puts "Current version: " +
      ActiveRecord::Migrator.current_version.to_s
  end

  #rake db:dump
  desc "dumps the devel database to a sql file"
  task :dump =&gt; :environment do
    puts "Creating .sql dump file. Enter mysql root password. Just press Enter for none"
    #run a shell command mysqldump -u user -p database name to file name
    `mysqldump -uroot -p app_development &gt; app_development_dump.sql`
  end

  #command line usage: rake db:dumpimport
  desc "imports the devel databse dump file to www2_sw"
  task :dumpimport =&gt; :environment do
    puts "Loading www2_sw_development_dump.sql. Enter mysql root password. Just press Enter for none"
    `mysql -uroot -p app_development &lt; app_development_dump.sql`
  end

end
</code>
</pre>
<p>Note you might want to use another mysql user to access your database. For example, <code>-u yourusername</code>. I like doing this so I can check in the dump file into subversion or whatever version control system you&#8217;re using. If you find this incredibly useful, you may want to <a href="http://errtheblog.com/posts/60-sake-bomb">sake</a> bomb it, which would make it available to all your projects. Bonus points for commenting on how to do this below (please?) It would also be cool to automatically grab the production database name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ivanenviroman.com/rake-tasks-for-dumping-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
