Description
Use domains in your migrations, with or without CREATE DOMAIN in your database!!.
Using this Ruby on Rails plugin you can write this code in your migrations file:
create_domain :activedom, :string, :limit => 5,
:default => 'False', :null => false do
value.in('True', 'False') | value.in('Yes', 'No')
end
create_table :projects do |t|
t.string :name, :limit => 60
t.string :description, :limit => 300
t.activedom :is_active # <- See that?: a domain in SQL is like an "user defined type"
t.timestamps
end
Usage
If your database engine supports ANSI-SQL92 domains (i.e. CREATE DOMAIN sentences) and you want to use it, put this in your environment:
ActiveRecord::Migration.supports_sql_domains true
The defualt is false: you can use create_domain in your migration, but CREATE DOMAIN sentences will not generated.
Installing
From your rails application path, type:
ruby script/plugin install https://domain-migrations-plugin.googlecode.com/svn/trunk/domain-migrations
Help
Please, use the news group refered in this page. You can write me english or spanish.