Re: Moving from MySQL to PostgreSQL with Ruby on Rails.
| От | Robby Russell |
|---|---|
| Тема | Re: Moving from MySQL to PostgreSQL with Ruby on Rails. |
| Дата | |
| Msg-id | 1132248231.5569.33.camel@linus обсуждение исходный текст |
| Ответ на | Moving from MySQL to PostgreSQL with Ruby on Rails. (Peter Michaux <petermichaux@gmail.com>) |
| Ответы |
Re: Moving from MySQL to PostgreSQL with Ruby on Rails.
|
| Список | 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 по дате отправления: