Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable logging during the run of database migrations?

I'm running rails migrations every time I run the test suite (using in-memory sqlite database). How to turn off output from the migrations?

Example output

-- create_table("alerts", {:force=>true})
  -> 0.0038s
-- create_table("businesses", {:force=>true})
  -> 0.0061s
etc...
like image 409
wifilinker Avatar asked Oct 03 '13 07:10

wifilinker


People also ask

How does rails keep track of migrations?

Every time a migration is generated using the rails g migration command, Rails generates the migration file with a unique timestamp. The timestamp is in the format YYYYMMDDHHMMSS . Whenever a migration is run, Rails inserts the migration timestamp into an internal table schema_migrations .

What is Active Record migration?

Migrations are a feature of Active Record that allows you to evolve your database schema over time. Rather than write schema modifications in pure SQL, migrations allow you to use a Ruby DSL to describe changes to your tables.

Can I delete migrations rails?

【Ruby on Rails】 When you want to delete a migration file you made, you can choose version and delete it. You don't need to execute rails db:rollback many times!


1 Answers

You can do it by calling ActiveRecord::Migration.verbose = false Reference: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/migration.rb#L253

like image 122
Madis Nõmme Avatar answered Oct 01 '22 10:10

Madis Nõmme