Module: RC::PrimaryKey

Included in:
ActiveRecord::ConnectionAdapters::Mysql2Adapter, ActiveRecord::ConnectionAdapters::MysqlAdapter, ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
Defined in:
lib/rein/constraint/primary_key.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_primary_key(table, options = {})



3
4
5
6
7
# File 'lib/rein/constraint/primary_key.rb', line 3

def add_primary_key(table, options = {})
  attribute = "id".to_sym
  sql = "ALTER TABLE #{table} ADD PRIMARY KEY (#{attribute})"
  execute(sql)
end