Module: DataMapper::Adapters::MysqlAdapter::Migration
- Includes:
- SQL
- Included in:
- DataMapper::Adapters::MysqlAdapter
- Defined in:
- lib/dm-core/adapters/mysql_adapter.rb
Overview
TODO: move to dm-more/dm-migrations
Defined Under Namespace
Modules: ClassMethods, SQL
Instance Method Summary collapse
-
#field_exists?(storage_name, field_name) ⇒ Boolean
TODO: move to dm-more/dm-migrations (if possible).
-
#storage_exists?(storage_name) ⇒ Boolean
TODO: move to dm-more/dm-migrations (if possible).
Instance Method Details
#field_exists?(storage_name, field_name) ⇒ Boolean
TODO: move to dm-more/dm-migrations (if possible)
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dm-core/adapters/mysql_adapter.rb', line 52 def field_exists?(storage_name, field_name) statement = <<-EOS.compress_lines SELECT COUNT(*) FROM `information_schema`.`columns` WHERE `table_schema` = ? AND `table_name` = ? AND `column_name` = ? EOS query(statement, db_name, storage_name, field_name).first > 0 end |
#storage_exists?(storage_name) ⇒ Boolean
TODO: move to dm-more/dm-migrations (if possible)
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dm-core/adapters/mysql_adapter.rb', line 39 def storage_exists?(storage_name) statement = <<-EOS.compress_lines SELECT COUNT(*) FROM `information_schema`.`tables` WHERE `table_type` = 'BASE TABLE' AND `table_schema` = ? AND `table_name` = ? EOS query(statement, db_name, storage_name).first > 0 end |