Make upgrade_instiki Rake Task Database-Agnostic
Reported by James Herdman.
This commit is contained in:
parent
93ea19f567
commit
c05d69bcff
|
@ -1,8 +1,9 @@
|
||||||
require 'sqlite3'
|
require 'active_record'
|
||||||
|
|
||||||
task :upgrade_instiki do
|
task :upgrade_instiki => :environment do
|
||||||
db = SQLite3::Database.new( "db/production.db.sqlite3" )
|
ActiveRecord::Base.establish_connection(:production)
|
||||||
db.execute( "select * from webs" ) do |row|
|
webs = ActiveRecord::Base.connection.execute( "select * from webs" )
|
||||||
|
webs.each do |row|
|
||||||
if File.exists?('public/' + row[4])
|
if File.exists?('public/' + row[4])
|
||||||
if File.exists?('webs/' + row[4])
|
if File.exists?('webs/' + row[4])
|
||||||
print "Warning! The directory webs/#{row[4]} already exists. Skipping.\n"
|
print "Warning! The directory webs/#{row[4]} already exists. Skipping.\n"
|
||||||
|
|
Loading…
Reference in a new issue