mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
changed activerecord / datamapper to sqlite in order to facilitate the testing of multiple databases
This commit is contained in:
parent
efed6b01bf
commit
7ee7654c48
2 changed files with 23 additions and 8 deletions
|
@ -1,15 +1,28 @@
|
|||
require 'active_record'
|
||||
db_dir = "#{File.dirname(__FILE__)}/../db"
|
||||
|
||||
ActiveRecord::Base.establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => ":memory:")
|
||||
ActiveRecord::Base.establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{db_dir}/activerecord_one.db")
|
||||
class SchemeInfo < ActiveRecord::Base
|
||||
end
|
||||
|
||||
ActiveRecord::Schema.define(:version => 1) do
|
||||
create_table :widgets do |t|
|
||||
t.string :name
|
||||
# check to see if the schema needs resetting (when using file based db)
|
||||
begin
|
||||
|
||||
result = ActiveRecord::Base.connection.execute("SELECT version FROM schema_migrations")
|
||||
raise StandardError unless result.first["version"] == "1"
|
||||
|
||||
rescue
|
||||
|
||||
ActiveRecord::Schema.define(:version => 1) do
|
||||
create_table :widgets do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :another_widgets do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
|
||||
create_table :another_widgets do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
|
||||
unless defined? Widget
|
||||
|
|
|
@ -5,7 +5,9 @@ require "dm-core"
|
|||
require "dm-validations"
|
||||
require "dm-aggregates"
|
||||
|
||||
DataMapper.setup(:default, "sqlite3::memory:")
|
||||
db_dir = "#{File.dirname(__FILE__)}/../db"
|
||||
|
||||
DataMapper.setup(:default, "sqlite3:#{db_dir}/datamapper_one.db")
|
||||
|
||||
class MapperWidget
|
||||
include DataMapper::Resource
|
||||
|
|
Loading…
Add table
Reference in a new issue