Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Compatibility with PostgreSQL

Signed-off-by: Pratik <pratiknaik@gmail.com>
  • Loading branch information...
commit df7aeb6d987e418afba535f11ec5066ef0d31783 1 parent 44e495c
@maxim maxim authored committed
Showing with 19 additions and 3 deletions.
  1. +19 −3 lib/tickle.rb
View
22 lib/tickle.rb
@@ -31,14 +31,30 @@ def run_tests(dir, n = 2)
# Wait...
Process.waitall
end
-
def prepare_databse(db)
- ActiveRecord::Base.establish_connection(db)
+ ActiveRecord::Base.establish_connection(db) unless postgres?
conf = ActiveRecord::Base.configurations
- ActiveRecord::Base.connection.recreate_database(conf[db.to_s]["database"], conf[db.to_s])
+
+ adapter = ActiveRecord::Base.connection
+ recreate_db(conf[db.to_s]["database"], adapter, conf)
+
ActiveRecord::Base.establish_connection(conf[db.to_s])
ActiveRecord::Schema.verbose = false
file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
load(file)
end
+
+ private
+ def postgres?
+ @postgres ||= ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
+ end
+
+ def recreate_db(db, adapter, options = {})
+ if postgres?
+ system("dropdb #{db}")
+ adapter.create_database(db)
+ else
+ adapter.recreate_database(db, options[db.to_s])
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.