Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # == Schema Information
- #
- # Table name: information_schema.table_constraints
- #
- # constraint_catalog :
- # constraint_schema :
- # constraint_name :
- # table_catalog :
- # table_schema :
- # table_name :
- # constraint_type :string
- # is_deferrable :string
- # initially_deferred :string
- #
- class TableConstraint < ActiveRecord::Base
- set_table_name 'information_schema.table_constraints'
- scope :foreign_keys, where('constraint_type = ?', 'FOREIGN KEY')
- scope :primary_keys, where('constraint_type = ?', 'PRIMARY KEY')
- def self.exists?(conditions)
- self.count(:conditions => conditions) > 0
- end
- end
Add Comment
Please, Sign In to add comment