Module: Ardb::MigrationHelpers
- Defined in:
- lib/ardb/migration_helpers.rb
Defined Under Namespace
Modules: RecorderMixin
Classes: ForeignKey
Class Method Summary
collapse
Class Method Details
.drop_foreign_key(*args) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/ardb/migration_helpers.rb', line 12
def drop_foreign_key(*args)
from_table, from_column = args[0..1]
options = args.last.kind_of?(Hash) ? args.last : {}
fk = ForeignKey.new(from_table, from_column, nil, options)
execute(fk.drop_sql)
end
|
.foreign_key(from_table, from_column, to_table, options = {}) ⇒ Object
7
8
9
10
|
# File 'lib/ardb/migration_helpers.rb', line 7
def foreign_key(from_table, from_column, to_table, options={})
fk = ForeignKey.new(from_table, from_column, to_table, options)
execute(fk.add_sql)
end
|
.remove_column_with_fk(table, column) ⇒ Object
19
20
21
22
|
# File 'lib/ardb/migration_helpers.rb', line 19
def remove_column_with_fk(table, column)
drop_foreign_key(table, column)
remove_column(table, column)
end
|