<?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>The Irish Penguin &#187; schema</title>
	<atom:link href="http://www.theirishpenguin.com/tag/schema/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theirishpenguin.com</link>
	<description>Watching Open Source unfold across Ireland</description>
	<lastBuildDate>Sun, 25 Jul 2010 17:53:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generate Rails Migrations from your PostgreSQL or MySQL database</title>
		<link>http://www.theirishpenguin.com/2009/11/26/generate-rails-migrations-from-your-postgresql-or-mysql-database/</link>
		<comments>http://www.theirishpenguin.com/2009/11/26/generate-rails-migrations-from-your-postgresql-or-mysql-database/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 21:33:59 +0000</pubDate>
		<dc:creator>theirishpenguin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[RubyIreland]]></category>
		<category><![CDATA[Rubyonrails]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[schema]]></category>

		<guid isPermaLink="false">http://www.theirishpenguin.com/?p=398</guid>
		<description><![CDATA[1) Create a new empty Rails project called schemer
2) In your config/database.yml file, point at the database you wish to dump to a migrations file
3) Run the command &#8216;rake db:schema:dump&#8217;. This should create a db/schema.rb file. Amazingly this effectively is your migrations file!
4) To tidy up create a file called file db/migrate/20091125205635_create_initial_schema.rb
5) Then copy the [...]]]></description>
			<content:encoded><![CDATA[<p>1) Create a new empty Rails project called schemer</p>
<p>2) In your config/database.yml file, point at the database you wish to dump to a migrations file</p>
<p>3) Run the command &#8216;rake db:schema:dump&#8217;. This should create a db/schema.rb file. Amazingly this effectively is your migrations file!</p>
<p>4) To tidy up create a file called file db/migrate/20091125205635_create_initial_schema.rb</p>
<p>5) Then copy the create_table statements from the schema.rb file into the new file 20091125205635_create_initial_schema.rb. Here&#8217;s a template</p>
<pre>class CreateInitialSchema &lt; ActiveRecord::Migration

  def self.up
    # Put all create_table statements from schema.rb file here
    # Note: You don't need the 'ActiveRecord::Schema.define(:version' line or it's enclosing end statement
    # ...
    # ...
  end

  def self.down
    # Don't really need this
  end

end</pre>
<p>6) Once you&#8217;ve all this done you can just run &#8216;rake db:migrate&#8217; and you should have a new sqlite db up and running under db/development.sqlite3</p>
<p>Thanks to Justin Ball on this Nobody Listens Anyway blog at <a href="http://www.justinball.com/2008/05/09/dump-an-existing-database-schema-into-a-ruby-on-rails-migration-ready-format/">Dump an Existing Database Schema Into a Ruby On Rails Migration Ready Format</a> for the basis of this tip. Sometimes somebody does&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theirishpenguin.com/2009/11/26/generate-rails-migrations-from-your-postgresql-or-mysql-database/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
