Module: SafePgMigrations::UselessStatementsLogger
- Defined in:
- lib/safe-pg-migrations/plugins/useless_statements_logger.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_check_constraint(table_name, expression, **options) ⇒ Object
- #add_foreign_key(from_table, to_table, **options) ⇒ Object
- #add_index(table_name, column_name, **options) ⇒ Object
- #remove_index(table_name, column_name = nil, **options) ⇒ Object
- #warn_for_index(**options) ⇒ Object
Class Method Details
.warn_useless(action, link = nil, *args) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/safe-pg-migrations/plugins/useless_statements_logger.rb', line 6 def warn_useless(action, link = nil, *args) Helpers::Logger.say( "/!\\ No need to explicitly use #{action}, safe-pg-migrations does it for you", *args ) Helpers::Logger.say "\t see #{link} for more details", *args if link end |
Instance Method Details
#add_check_constraint(table_name, expression, **options) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/safe-pg-migrations/plugins/useless_statements_logger.rb', line 31 def add_check_constraint(table_name, expression, **) if [:validate] == false UselessStatementsLogger.warn_useless '`validate: :false`', 'https://github.com/doctolib/safe-pg-migrations#safe_add_check_constraint' end super end |
#add_foreign_key(from_table, to_table, **options) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/safe-pg-migrations/plugins/useless_statements_logger.rb', line 24 def add_foreign_key(from_table, to_table, **) if [:validate] == false UselessStatementsLogger.warn_useless '`validate: :false`', 'https://github.com/doctolib/safe-pg-migrations#safe_add_foreign_key' end super end |
#add_index(table_name, column_name, **options) ⇒ Object
14 15 16 17 |
# File 'lib/safe-pg-migrations/plugins/useless_statements_logger.rb', line 14 def add_index(table_name, column_name, **) warn_for_index(**) super end |
#remove_index(table_name, column_name = nil, **options) ⇒ Object
19 20 21 22 |
# File 'lib/safe-pg-migrations/plugins/useless_statements_logger.rb', line 19 def remove_index(table_name, column_name = nil, **) warn_for_index(**) unless .empty? super end |
#warn_for_index(**options) ⇒ Object
38 39 40 41 42 |
# File 'lib/safe-pg-migrations/plugins/useless_statements_logger.rb', line 38 def warn_for_index(**) return unless [:algorithm] == :concurrently UselessStatementsLogger.warn_useless '`algorithm: :concurrently`', 'https://github.com/doctolib/safe-pg-migrations#safe_add_remove_index' end |