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 = " SELECT COUNT(*)\n FROM `information_schema`.`columns`\n WHERE `table_schema` = ?\n AND `table_name` = ?\n AND `column_name` = ?\n EOS\n\n query(statement, db_name, storage_name, field_name).first > 0\nend\n".compress_lines |
#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 = " SELECT COUNT(*)\n FROM `information_schema`.`tables`\n WHERE `table_type` = 'BASE TABLE'\n AND `table_schema` = ?\n AND `table_name` = ?\n EOS\n\n query(statement, db_name, storage_name).first > 0\nend\n".compress_lines |