aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/db_drop.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/db_drop.rb')
-rw-r--r--lib/sisu/v6/db_drop.rb38
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/sisu/v6/db_drop.rb b/lib/sisu/v6/db_drop.rb
index 94fc5e99..926da47f 100644
--- a/lib/sisu/v6/db_drop.rb
+++ b/lib/sisu/v6/db_drop.rb
@@ -64,11 +64,11 @@
module SiSU_DbDrop
class Drop
require_relative 'response' # response.rb
- def initialize(opt,conn,db_info,sql_type='')
+ def initialize(opt,conn,db_info,sql_type)
@opt,@conn,@db_info,@sql_type=opt,conn,db_info,sql_type
@ans=SiSU_Response::Response.new
case @sql_type
- when /sqlite/
+ when :sqlite
cascade=''
else
cascade='CASCADE'
@@ -87,7 +87,7 @@ module SiSU_DbDrop
begin
msg_sqlite="as not all disk space is recovered after dropping the database << #{@db_info.sqlite.db} >>, you may be better off deleting the file, and recreating it as necessary"
case @sql_type
- when /sqlite/
+ when :sqlite
puts msg_sqlite
ans=@ans.response?('remove sql database?')
if ans \
@@ -118,24 +118,38 @@ module SiSU_DbDrop
else
@conn.transaction
@drop_table.each do |d|
- @conn.execute(d)
- end
+ begin
+ @conn.exec_params(d)
+ rescue
+ next
+ end
+ end
@conn.commit
end
- else
+ when :pg
+ @conn.transaction
@drop_table.each do |d|
- @conn.execute(d)
+ begin
+ @conn.exec_params(d)
+ rescue
+ next
+ end
end
+ @conn.commit
end
rescue
case @sql_type
- when /sqlite/
+ when :sqlite
ans=@ans.response?('remove sql database?')
if ans and File.exist?(@db_info.sqlite.db); File.unlink(@db_info.sqlite.db)
end
else
@drop_table.each do |d|
- @conn.execute(d)
+ begin
+ @conn.exec_params(d)
+ rescue
+ next
+ end
end
end
ensure
@@ -145,7 +159,11 @@ module SiSU_DbDrop
def conn_execute_array(sql_arr)
@conn.transaction do |conn|
sql_arr.each do |sql|
- conn.execute(sql)
+ begin
+ conn.exec_params(sql)
+ rescue
+ next
+ end
end
end
end