I Repeat... Do Not Use PostgreSQL!
3 comments Latest by Rick M. Wed, 15 Mar 2006 01:38:40 GMT
Why is everybody interested in using PostgreSQL? We all know that it’s a pain to install, a pain to maintain, and Rails only works with MySQL. So, why do we bother?
This article titled, Five reasons why you should never use PostgreSQL. Ever. clears up these questions.
My favorite is… “Reason #5: You (don’t) get what you (don’t) pay for”
Imagine if we said the same thing about Ruby on Rails?
Similar Post(s): The bitter-sweet taste of agnostic database schemas, Localization with Rails and PostgreSQL, part 1
Localization with Rails and PostgreSQL, part 1
1 comment Latest by highstatesmanship@gmail.com Wed, 28 Jun 2006 03:43:44 GMT
One of the client projects that PLANET ARGON is working on requires that it work in about 20 different languages. Jeremy has been investigating different plugins for Rails to help us accomplish this. He came across Globalize.
Globalize is a Ruby on Rails plugin designed to support multilingual applications. It’s under the MIT License, same as Ruby on Rails.
Locale.set( 'en-US' )
d = Diet.find( 1 )
d.name -> "Vegetarian"
... we want to pull back the German version. No, it doesn’t translate it for you.. just pulls back another version of the object with the desired locale.
Locale.set( 'de-DE' )
d = Diet.find( 1 )
d.name -> "Vegetarier"
Pretty cool, right?
Well, we’re primarily working with PostgreSQL and the Globalize plugin didn’t pass tests with it. That’s now fixed as I found out from Jeremy that he was given COMMIT rights to the Globalize plugin and it now passes all tests against PostgreSQL!
We’ll keep you updated on how well it works as we dig deeper into using it. :-)
Interviewed by CRN regarding Oracle, MySQL, and PostgreSQL
I was interviewed by CRN regarding my personal thoughts on how the release of Oracle Express might compete with MySQL and PostgreSQL.
Oracle Express… {yawn}
Rails Migrations and PostgreSQL Constraints
A question was posed on the Rails mailing list concerning how one would go about adding CONSTRAINTs to the database tables with ActiveRecord::Migration.
One argument was raised stating that it is easier to handle these in plain SQL schema files. I disagree. :-)
Migrations to the Rescue
Databases evolve and I have recently found the Migration structure to be perfect for handling iterations and schema changes. Using the #execute method has helped move more of my code into the Ruby/Rails framework… and that just makes things easier to manage in the long-run. This is the approach that we are using at PLANET ARGON with some of our current client projects.
# db/migrate/6_add_foreign_key.rb
class AddForeignKey < ActiveRecord::Migration
def self.up
execute "ALTER TABLE bees ADD CONSTRAINT beehive_id_fkey FOREIGN KEY
(beehive_id) REFERENCES beehives (id);"
end
def self.down
execute "ALTER TABLE bees DROP CONSTRAINT beehive_id_fkey;"
end
end
This gives us an easy way to use the standard, #create_table syntax for building our tables with Ruby… and then we can slap these constraints on later.
This would add the constraints…
rake migrate VERSION=6
...run tests…
rake
...roll back…
rake migrate VERSION=5
I have found that this approach is really useful with testing in Rails. When I think that I have everything working great (without CONSTRAINTS in PostgreSQL), I run another migration to add a bunch of foreign key and data constraints to the tables and… run my tests again.
Let’s give Active Record a Hug
This has helped me gain some trust in Active Record while still giving me that comforting feeling that PostgreSQL is acting as the body guard for my data.
Even if you don’t end up using Migrations to handle these types of database schema changes, I would highly suggest that you model your implementation after this. I’ve worked with many database schemas and this just makes it easy to add your new change and run one command to commit it to the database.
...and now I go play with beehives…
PostgreSQL 8.1 was released!
Just a quick announcemnet:
Yesterday, the PostgreSQL team released version 8.1. Take a peak at the latest changes and enhancements.
Yes, we’re offering PostgreSQL 8.1 Hosting and Support for it now at PLANET ARGON. :-)
Interview with CD Baby
Last month I conducted an interview with Derek Sivers and Jeremy Kemper of CD Baby… this is the result.