lib/combustion/database.rb in combustion-0.3.2 vs lib/combustion/database.rb in combustion-0.3.3

- old
+ new

@@ -18,12 +18,12 @@ when /postgresql/ ActiveRecord::Base.clear_active_connections! drop_database(abcs['test']) create_database(abcs['test']) when /sqlite/ - dbfile = abcs['test']['database'] || abcs['test']['dbfile'] - File.delete(dbfile) if File.exist?(dbfile) + drop_database(abcs['test']) + create_database(abcs['test']) when 'sqlserver' test = abcs.deep_dup['test'] test_database = test['database'] test['database'] = 'master' ActiveRecord::Base.establish_connection(test) @@ -40,20 +40,30 @@ raise "Cannot reset databases for '#{abcs['test']['adapter']}'" end end def self.load_schema - load "#{Rails.root}/db/schema.rb" + case Combustion.schema_format + when :ruby + load Rails.root.join('db', 'schema.rb') + when :sql + ActiveRecord::Base.connection.execute( + File.read(Rails.root.join('db', 'structure.sql')) + ) + else + raise "Unknown schema format: #{Combustion.schema_format}" + end end def self.migrate migrator = ActiveRecord::Migrator - paths = 'db/migrate/' + paths = Array('db/migrate/') if migrator.respond_to?(:migrations_paths) - paths = migrator.migrations_paths + paths = migrator.migrations_paths end - + # Append the migrations inside the internal app's db/migrate directory + paths << File.join(Rails.root, 'db/migrate') migrator.migrate paths, nil end private