merb_activerecord 1.0.0 → 1.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/active_record/merbtasks.rb +15 -8
- data/lib/merb_activerecord.rb +3 -3
- metadata +1 -1
data/Rakefile
CHANGED
@@ -53,14 +53,21 @@ namespace :db do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def drop_database(config)
|
56
|
-
|
57
|
-
|
58
|
-
ActiveRecord::Base.connection
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
begin
|
57
|
+
ActiveRecord::Base.establish_connection(config)
|
58
|
+
ActiveRecord::Base.connection
|
59
|
+
rescue
|
60
|
+
puts "could not connect to #{config[:database]}, database not dropped"
|
61
|
+
else
|
62
|
+
case config[:adapter]
|
63
|
+
when 'mysql'
|
64
|
+
ActiveRecord::Base.connection.drop_database config[:database]
|
65
|
+
when /^sqlite/
|
66
|
+
FileUtils.rm(File.join(Merb.root, config[:database]))
|
67
|
+
when 'postgresql'
|
68
|
+
ActiveRecord::Base.clear_active_connections!
|
69
|
+
`dropdb "#{config[:database]}"`
|
70
|
+
end
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
data/lib/merb_activerecord.rb
CHANGED
@@ -27,10 +27,10 @@ if defined?(Merb::Plugins)
|
|
27
27
|
|
28
28
|
def self.run
|
29
29
|
Merb.logger.debug "Disconnecting database connection before forking."
|
30
|
-
::ActiveRecord::Base.
|
30
|
+
::ActiveRecord::Base.clear_active_connections!
|
31
31
|
end
|
32
|
-
|
33
|
-
|
32
|
+
end
|
33
|
+
|
34
34
|
|
35
35
|
generators = File.join(File.dirname(__FILE__), 'generators')
|
36
36
|
Merb.add_generators generators / :migration
|