Permalink
Browse files

Avoid "no such table" exception when schema migrations table does not…

… exist

[#4990 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 0e5d7c6 commit 4f74d449eee1e3d1621ed032532076492a1bf0b3 @amatsuda amatsuda committed with jeremy Jun 28, 2010
Showing with 5 additions and 0 deletions.
  1. +5 −0 activerecord/lib/active_record/railties/databases.rake
@@ -175,6 +175,11 @@ namespace :db do
desc "Display status of migrations"
task :status => :environment do
config = ActiveRecord::Base.configurations[Rails.env || 'development']
+ ActiveRecord::Base.establish_connection(config)
+ unless ActiveRecord::Base.connection.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name)
+ puts 'Schema migrations table does not exist yet.'
+ next # means "return" for rake task
+ end
db_list = ActiveRecord::Base.connection.select_values("SELECT version FROM #{ActiveRecord::Migrator.schema_migrations_table_name}")
file_list = []
Dir.foreach(File.join(Rails.root, 'db', 'migrate')) do |file|

0 comments on commit 4f74d44

Please sign in to comment.