From: | Robby Russell <robby(dot)lists(at)planetargon(dot)com> |
---|---|
To: | Peter Michaux <petermichaux(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Moving from MySQL to PostgreSQL with Ruby on Rails. |
Date: | 2005-11-17 17:23:51 |
Message-ID: | 1132248231.5569.33.camel@linus |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
*******************************************************/
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Atkins | 2005-11-17 17:33:11 | Re: Rebranding PostgreSQL |
Previous Message | Michael Fuhr | 2005-11-17 17:06:51 | Re: Very slow queries on 8.1 |