<?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; database</title>
	<atom:link href="http://www.theirishpenguin.com/tag/database/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>Getting started with PostgreSQL when developing Rails applications</title>
		<link>http://www.theirishpenguin.com/2010/05/07/getting-started-with-postgresql-when-developing-rails-applications/</link>
		<comments>http://www.theirishpenguin.com/2010/05/07/getting-started-with-postgresql-when-developing-rails-applications/#comments</comments>
		<pubDate>Thu, 06 May 2010 18:24:31 +0000</pubDate>
		<dc:creator>theirishpenguin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://www.theirishpenguin.com/?p=545</guid>
		<description><![CDATA[If you&#8217;re familiar with MySQL and trying out PostgreSQL for the first time while doing some Ruby on Rails development, things can initially seem quite unfamiliar. A great first article to look at is available on the OLM on Rails site at Switching Rails to PostgreSQL. Also at this early stage in your PG career [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re familiar with MySQL and trying out PostgreSQL for the first time while doing some Ruby on Rails development, things can initially seem quite unfamiliar. A great first article to look at is available on the OLM on Rails site at <a href="http://olmonrails.wordpress.com/2008/08/12/switching-rails-to-postgresql/">Switching Rails to PostgreSQL</a>. Also at this early stage in your PG career you&#8217;ll need to know how to change things like user passwords so check the Examples section of the <a href="http://www.postgresql.org/docs/8.0/interactive/sql-alteruser.html">PostgreSQL Alter User docs</a>.</p>
<p>Ok, after that you should know how to create a database in PostgreSQL, hook up to a Rails app and run migrations. Once that&#8217;s done, you&#8217;ll need to be able to do the same things that you were able to do in MySQL in the psql shell. Here&#8217;s the first commands you need&#8230;</p>
<ul>
<li>typing &#8216;help&#8217; displays help at any time</li>
<li>\? displays help with psql commands</li>
<li>\l lists databases</li>
<li>\c some_database connects to a database</li>
<li>\c with no argument tells you what database you&#8217;re currently connected to</li>
<li>\ds lists schemas within the currently selected database. A schema is simply a namespacing of tables within a given database</li>
<li>\dt lists tables in the currently selected database</li>
<li>\du lists all postgres database user accounts (more detail <a title="How to list postgres user accounts?" href="http://archives.postgresql.org/pgsql-admin/2005-07/msg00073.php">here</a>)</li>
</ul>
<p>Here&#8217;s  a list of good of stuff&#8230;</p>
<ul>
<li>The &#8216;LIKE&#8217; pattern matcher in Postgres is case sensitive (in MySQL it is case insensitive &#8211; to get this behaviour in Postgres use &#8216;ILIKE&#8217;)</li>
<li><a title="What are schemas in PostgreSQL?" href="http://sql-info.de/postgresql/schemas.html">What are schemas in PostgreSQL?</a></li>
<li>If you want to keep things simple, just forget about schemas and everything will end up in a &#8216;public&#8217; schema (but you should read about schemas briefly so that they don&#8217;t drive you mad when administering your postgres database)</li>
<li><a title="Postgres Gotchas" href="http://sql-info.de/postgresql/postgres-gotchas.html">Postgres Gotchas</a></li>
<li><a title="Switching from MySQL to PostgreSQL - tips, tricks and gotchas?" href="http://stackoverflow.com/questions/772111/switching-from-mysql-to-postgresql-tips-tricks-and-gotchas">Switching from MySQL to PostgreSQL &#8211; tips, tricks and gotchas?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.theirishpenguin.com/2010/05/07/getting-started-with-postgresql-when-developing-rails-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>
