Guest User

Untitled

a guest
Jun 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # == Schema Information
  2. #
  3. # Table name: information_schema.table_constraints
  4. #
  5. # constraint_catalog :
  6. # constraint_schema :
  7. # constraint_name :
  8. # table_catalog :
  9. # table_schema :
  10. # table_name :
  11. # constraint_type :string
  12. # is_deferrable :string
  13. # initially_deferred :string
  14. #
  15.  
  16. class TableConstraint < ActiveRecord::Base
  17. set_table_name 'information_schema.table_constraints'
  18.  
  19. scope :foreign_keys, where('constraint_type = ?', 'FOREIGN KEY')
  20. scope :primary_keys, where('constraint_type = ?', 'PRIMARY KEY')
  21.  
  22. def self.exists?(conditions)
  23. self.count(:conditions => conditions) > 0
  24. end
  25. end
Add Comment
Please, Sign In to add comment