This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yank out the DB options and only use in-memory SQLite
- Loading branch information
1 parent
7f5ea53
commit e3f1f3b
Showing
3 changed files
with
14 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
Gemfile.lock | ||
pkg/* | ||
.rvmrc | ||
spec/db/database.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,9 @@ | ||
require 'yaml' | ||
# Create schema and load the models | ||
ActiveRecord::Base.establish_connection({:adapter => "sqlite3", :database => ":memory:"}) | ||
|
||
ENV['DB'] ||= 'sqlite3' | ||
ActiveRecord::Base.silence do | ||
ActiveRecord::Migration.verbose = false | ||
|
||
database_yml = File.expand_path('../../db/database.yml', __FILE__) | ||
if File.exists?(database_yml) | ||
active_record_configuration = YAML.load_file(database_yml)[ENV['DB']] | ||
|
||
ActiveRecord::Base.establish_connection(active_record_configuration) | ||
|
||
ActiveRecord::Base.silence do | ||
ActiveRecord::Migration.verbose = false | ||
|
||
load(File.dirname(__FILE__) + '/../db/schema.rb') | ||
load(File.dirname(__FILE__) + '/../db/models.rb') | ||
end | ||
|
||
else | ||
abort <<-FAIL | ||
Please create #{database_yml} first to configure your database. | ||
Take a look at: #{database_yml}.example" | ||
FAIL | ||
end | ||
|
||
def clean_database! | ||
[SimpleDocument].each do |model| | ||
ActiveRecord::Base.connection.execute "DELETE FROM #{model.table_name}" | ||
end | ||
end | ||
|
||
clean_database! | ||
load(File.dirname(__FILE__) + '/../db/schema.rb') | ||
load(File.dirname(__FILE__) + '/../db/models.rb') | ||
end |