aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/db_drop.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/db_drop.rb')
-rw-r--r--lib/sisu/v3dv/db_drop.rb187
1 files changed, 0 insertions, 187 deletions
diff --git a/lib/sisu/v3dv/db_drop.rb b/lib/sisu/v3dv/db_drop.rb
deleted file mode 100644
index 4b9aba7d..00000000
--- a/lib/sisu/v3dv/db_drop.rb
+++ /dev/null
@@ -1,187 +0,0 @@
-# encoding: utf-8
-=begin
-
- * Name: SiSU
-
- * Description: a framework for document structuring, publishing and search
-
- * Author: Ralph Amissah
-
- * Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved.
-
- * License: GPL 3 or later:
-
- SiSU, a framework for document structuring, publishing and search
-
- Copyright (C) Ralph Amissah
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program. If not, see <http://www.gnu.org/licenses/>.
-
- If you have Internet connection, the latest version of the GPL should be
- available at these locations:
- <http://www.fsf.org/licensing/licenses/gpl.html>
- <http://www.gnu.org/licenses/gpl.html>
-
- <http://www.jus.uio.no/sisu/gpl.fsf/toc.html>
- <http://www.jus.uio.no/sisu/gpl.fsf/doc.html>
- <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt>
-
- * SiSU uses:
- * Standard SiSU markup syntax,
- * Standard SiSU meta-markup syntax, and the
- * Standard SiSU object citation numbering and system
-
- * Hompages:
- <http://www.jus.uio.no/sisu>
- <http://www.sisudoc.org>
-
- * Download:
- <http://www.jus.uio.no/sisu/SiSU/download.html>
-
- * Ralph Amissah
- <ralph@amissah.com>
- <ralph.amissah@gmail.com>
-
- ** Description: modules shared by the different db types, dbi, postgresql,
- sqlite
-
-=end
-module SiSU_DbDrop
- class Drop
- require_relative 'response' # response.rb
- 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/
- cascade=''
- else
- cascade='CASCADE'
- end
- @drop_table=[
- "DROP TABLE metadata_and_text #{cascade};",
- "DROP TABLE doc_objects #{cascade};",
- "DROP TABLE urls #{cascade};",
- "DROP TABLE endnotes #{cascade};",
- "DROP TABLE endnotes_asterisk #{cascade};",
- "DROP TABLE endnotes_plus #{cascade};",
- ]
- end
- def drop
- def tables #% drop all tables
- 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/
- puts msg_sqlite
- ans=@ans.response?('remove sql database?')
- if ans \
- and File.exist?(@db_info.sqlite.db)
- @conn.close
- File.unlink(@db_info.sqlite.db)
- db=SiSU_Env::InfoDb.new
- conn=db.sqlite.conn_sqlite3
- sdb=SiSU_DbDBI::Create.new(@opt,conn,@db_info,@sql_type)
- sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@db_info,@sql_type)
- sdb.output_dir?
- begin
- sdb.create_db
- sdb.create_table.metadata_and_text
- sdb.create_table.doc_objects
- sdb.create_table.endnotes
- sdb.create_table.endnotes_asterisk
- sdb.create_table.endnotes_plus
- sdb.create_table.urls
- sdb_index.create_indexes
- rescue; SiSU_Errors::InfoError.new($!,$@,'-D').error; sdb.output_dir?
- end
- exit
- else
- @conn.transaction
- @drop_table.each do |d|
- @conn.execute(d)
- end
- @conn.commit
- end
- else
- @drop_table.each do |d|
- @conn.execute(d)
- end
- end
- rescue
- case @sql_type
- 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)
- end
- end
- ensure
- end
- end
- def indexes
- def conn_execute_array(sql_arr)
- @conn.transaction do |conn|
- sql_arr.each do |sql|
- conn.execute(sql)
- end
- end
- end
- def base #% drop base indexes
- print "\n drop documents common indexes\n" unless @opt.cmd =~/q/
- sql_arr=[
- %{DROP INDEX idx_title;},
- %{DROP INDEX idx_author;},
- %{DROP INDEX idx_filename;},
- %{DROP INDEX idx_topics;},
- %{DROP INDEX idx_ocn;},
- %{DROP INDEX idx_digest_clean;},
- %{DROP INDEX idx_digest_all;},
- %{DROP INDEX idx_lev1;},
- %{DROP INDEX idx_lev2;},
- %{DROP INDEX idx_lev3;},
- %{DROP INDEX idx_lev4;},
- %{DROP INDEX idx_lev5;},
- %{DROP INDEX idx_lev6;},
- %{DROP INDEX idx_endnote_nr;},
- %{DROP INDEX idx_digest_en;},
- %{DROP INDEX idx_endnote_nr_asterisk;},
- %{DROP INDEX idx_endnote_asterisk;},
- %{DROP INDEX idx_digest_en_asterisk;},
- %{DROP INDEX idx_endnote_nr_plus;},
- %{DROP INDEX idx_endnote_plus;},
- %{DROP INDEX idx_digest_en_plus},
- ]
- conn_execute_array(sql_arr)
- end
- def text #% drop TEXT indexes, sqlite
- print "\n drop documents TEXT indexes\n" unless @opt.cmd =~/q/
- sql_arr=[
- %{DROP INDEX idx_clean;},
- %{DROP INDEX idx_endnote},
- ]
- conn_execute_array(sql_arr)
- end
- self
- end
- indexes.base
- @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : indexes.text)
- self
- end
- end
-end
-__END__