Re: Moving from MySQL to PostgreSQL with Ruby on Rails. - Mailing list pgsql-general

From Robby Russell
Subject Re: Moving from MySQL to PostgreSQL with Ruby on Rails.
Date
Msg-id 1132248231.5569.33.camel@linus
Whole thread Raw
In response to Moving from MySQL to PostgreSQL with Ruby on Rails.  (Peter Michaux <petermichaux@gmail.com>)
Responses Re: Moving from MySQL to PostgreSQL with Ruby on Rails.  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
On Thu, 2005-11-17 at 08:48 -0800, Peter Michaux wrote:
> Hi,
>
> I'm just new to the PostgreSQL world. I've been using MySQL but I want
> to develop a Ruby on Rails application that can be installed on either
> MySQL or PostgreSQL. I don't know how much the DDL dialects vary
> between them. At the moment I am interested in the options on a table
> like UTF-8. In MySQL I write
>
> CREATE TABLE product (
>   id INT NOT NULL AUTOINCREMENT,
>   name VARCHAR(255) NOT NULL DEFAULT '',
>   PRIMARY KEY (id)
> ) DEFAULT CHARSET=UTF-8;
>
> Will this definition work in the PostgreSQL world? Is there a web page
> for people with MySQL exerience moving to PostgreSQL?
>

CREATE TABLE product (
  id SERIAL PRIMARY KEY,
  name VARCHAR(255) NOT NULL DEFAULT '',
);


> Part of the issue is the way Ruby on Rails migration class enables me
> to add options to Rails' own abstraced DDL just like I have done in
> the above example. Other ways of adding options might be tricky.

With ActiveRecord::Migration:

# db/migrate/1_initial.rb
class Initial < ActiveRecord::Migration

  def self.up
    create_table :products do |t|
      t.column :name, :string, :default => ''
    end
  end

  # drop all tables 'rake migrate VERSION=0'
  def self.down
    drop_table :products
  end

end

# Run from main Rails directory
rake migrate

Using either plain SQL like above or AR::Migrate will generate the same table structure.


Cheers,

-Robby

--
/******************************************************
* Robby Russell, Founder.Developer.Geek
* PLANET ARGON, Rails Development, Consulting & Hosting
* Portland, Oregon  | p: 503.351.4730 | f: 815.642.4068
* www.planetargon.com | www.robbyonrails.com
* Programming Rails   | www.programmingrails.com
*******************************************************/


pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Very slow queries on 8.1
Next
From: David Rysdam
Date:
Subject: Re: Very slow queries on 8.1