07/04/04 23:25:28
>>165
$ rails zoo -d sqlite3
$ ./script/generate model Animal
class CreateAnimals < ActiveRecord::Migration
def self.up
create_table :animals do |t|
t.column :name, :string
t.column :leg, :integer, :default => 4
end
end
end
$ rake db:migrate
$ ./script/runner 'puts Animal.new.leg'
4
とかいう結果になったぜ。
sqlite> .dump 'animals'
BEGIN TRANSACTION;
CREATE TABLE animals ("id" INTEGER PRIMARY KEY NOT NULL, "name" varchar(255) DEFAULT NULL, "leg" integer DEFAULT 4);
COMMIT;