Skip to content

Instantly share code, notes, and snippets.

@maxim
Created November 19, 2008 16:49
Show Gist options
  • Save maxim/26575 to your computer and use it in GitHub Desktop.
Save maxim/26575 to your computer and use it in GitHub Desktop.
class AddConstraintsToAssets < ActiveRecord::Migration
def self.up
execute "alter table #{Asset.table_name}
add constraint assets_check_kind
check (kind in (#{ Asset::KINDS.collect{|a| "'#{a}'"}.join(',') }));".to_line
end
def self.down
execute "alter table #{Asset.table_name}
drop constraint assets_check_kind;".to_line
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment