Class: Baza::Driver::Mysql::ForeignKey
- Inherits:
-
ForeignKey
- Object
- ForeignKey
- Baza::Driver::Mysql::ForeignKey
- Defined in:
- lib/baza/driver/mysql/foreign_key.rb
Instance Attribute Summary
Attributes inherited from ForeignKey
#column_name, #db, #name, #referenced_column_name, #referenced_table_name, #table_name
Instance Method Summary collapse
- #drop ⇒ Object
-
#initialize(args) ⇒ ForeignKey
constructor
A new instance of ForeignKey.
Methods inherited from ForeignKey
Methods included from Baza::DatabaseModelFunctionality
Constructor Details
#initialize(args) ⇒ ForeignKey
Returns a new instance of ForeignKey.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/baza/driver/mysql/foreign_key.rb', line 2 def initialize(args) @db = args.fetch(:db) data = args.fetch(:data) @column_name = data.fetch(:COLUMN_NAME) @name = data.fetch(:CONSTRAINT_NAME) @table_name = data.fetch(:TABLE_NAME) @referenced_table_name = data.fetch(:REFERENCED_TABLE_NAME) @referenced_column_name = data.fetch(:REFERENCED_COLUMN_NAME) end |
Instance Method Details
#drop ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/baza/driver/mysql/foreign_key.rb', line 14 def drop @db.query(" ALTER TABLE #{@db.quote_table(table_name)} DROP FOREIGN KEY #{@db.quote_table(name)} ") true end |