]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/composite_primary_keys-2.2.2/tasks/databases/sqlite3.rake
Handle Timeout::Error exceptions which are caught by ActiveRecord.
[rails.git] / vendor / gems / composite_primary_keys-2.2.2 / tasks / databases / sqlite3.rake
1 namespace :sqlite3 do
2   desc 'Build the sqlite test databases'
3   task :build_databases => :load_connection do 
4     file = File.join(SCHEMA_PATH, 'sqlite.sql')
5     dbfile = File.join(PROJECT_ROOT, ENV['cpk_adapter_options_str'])
6     cmd = "mkdir -p #{File.dirname(dbfile)}"
7     puts cmd
8     sh %{ #{cmd} }
9     cmd = "sqlite3 #{dbfile} < #{file}"
10     puts cmd
11     sh %{ #{cmd} }
12   end
13
14   desc 'Drop the sqlite test databases'
15   task :drop_databases => :load_connection do 
16     dbfile = ENV['cpk_adapter_options_str']
17     sh %{ rm -f #{dbfile} }
18   end
19
20   desc 'Rebuild the sqlite test databases'
21   task :rebuild_databases => [:drop_databases, :build_databases]
22
23   task :load_connection do
24     require File.join(PROJECT_ROOT, %w[lib adapter_helper sqlite3])
25     spec = AdapterHelper::Sqlite3.load_connection_from_env
26     ENV['cpk_adapter_options_str'] = spec[:dbfile]
27   end
28 end