| Class | ActiveRecord::ConnectionAdapters::AbstractAdapter |
| In: |
lib/access_db_helpers.rb
|
| Parent: | Object |
Convenience method — declare the :owner_id and :owner_firm_id columns in the table named ‘table_name’, and add conventional indexes on them; most access-controlled tables will have these.
# File lib/access_db_helpers.rb, line 30
30: def add_owner_access_control_keys_and_indexes_for( table_name )
31: add_column table_name, :owner_id, :integer,
32: :foreign_key => {:table => :users, :name=>"fk_#{table_name}_owner"},
33: :null => false
34: add_column table_name, :owner_firm_id, :integer,
35: :foreign_key => {:table => :firms,
36: :name => "fk_#{table_name}_firm"},
37: :null => false
38:
39: # Try to avoid bumping up against Oracle name-length limits...
40:
41: add_index table_name, :owner_id,
42: :name => "#{table_name}_by_owner"
43: add_index table_name, :owner_firm_id,
44: :name => "#{table_name}_by_firm"
45: end