From: Joe Van Dyk Date: 2005-07-18T22:34:49+09:00 Subject: Re: Just seen on c.l.py On 7/17/05, JZ wrote: > On Sun, 17 Jul 2005 23:35:21 +0200, JZ wrote: > > >> But it can certainly also be used to create your entire database from > >> scratch, so that you won't have to touch SQL at all. Example: > >> > >> create_table :system_settings do |t| > >> t.column :name, :string > >> t.column :label, :string > >> t.column :value, :text > >> t.column :type, :string > >> t.column :position, :integer > >> end > > > > David, how would you define collations or constrains here? > > To be more specific... how to prepare "create_table :system_settings ..." > code for such table: > > CREATE TABLE `book` ( > `id` int(10) unsigned NOT NULL auto_increment, > `book_id` varchar(3) character set utf8 NOT NULL default '', > `chapter_nr` smallint(5) unsigned NOT NULL default '0', > `verse_nr` smallint(5) unsigned NOT NULL default '0', > `verse` text collate utf8_polish_ci NOT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY `idx_uniq` (`book_id`,`chapter_nr`,`verse_nr`) > ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci; See http://api.rubyonrails.org/classes/ActiveRecord/Migration.html I don't see collate in there yet, but it shouldn't be a hard patch. I know that you can give the table creation statement an option string that gets appended to the table sql definition, so that's one part of it.