diff options
Diffstat (limited to 'lib/sisu/v2/db_drop.rb')
-rw-r--r-- | lib/sisu/v2/db_drop.rb | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/lib/sisu/v2/db_drop.rb b/lib/sisu/v2/db_drop.rb index 7189da56..edd08345 100644 --- a/lib/sisu/v2/db_drop.rb +++ b/lib/sisu/v2/db_drop.rb @@ -133,38 +133,53 @@ module SiSU_DB_drop ensure end end - def indexes #% drop all indexes - #@conn.do(%{ - # DROP INDEX object_nr ON doc_objects(ocn); - # DROP INDEX body ON doc_objects(body); - # DROP INDEX clean ON doc_objects(clean); - # DROP INDEX lev1 ON doc_objects(lev1); - # DROP INDEX lev2 ON doc_objects(lev2); - # DROP INDEX lev3 ON doc_objects(lev3); - # DROP INDEX lev4 ON doc_objects(lev4); - # DROP INDEX lev5 ON doc_objects(lev5); - # DROP INDEX lev6 ON doc_objects(lev6); - # DROP INDEX endnote_nr ON endnotes(nr); - # DROP INDEX endnote ON endnotes(body); - # DROP INDEX title ON metadata_and_text(title); - # DROP INDEX filename ON metadata_and_text(filename) - # /* - # DROP INDEX object_nr ON doc_objects(ocn) CASCADE; - # DROP INDEX body ON doc_objects(body) CASCADE; - # DROP INDEX clean ON doc_objects(clean) CASCADE; - # DROP INDEX lev1 ON doc_objects(lev1) CASCADE; - # DROP INDEX lev2 ON doc_objects(lev2) CASCADE; - # DROP INDEX lev3 ON doc_objects(lev3) CASCADE; - # DROP INDEX lev4 ON doc_objects(lev4) CASCADE; - # DROP INDEX lev5 ON doc_objects(lev5) CASCADE; - # DROP INDEX lev6 ON doc_objects(lev6) CASCADE; - # DROP INDEX endnote_nr ON endnotes(nr) CASCADE; - # DROP INDEX endnote ON endnotes(body) CASCADE; - # DROP INDEX title ON metadata_and_text(title) CASCADE; - # DROP INDEX filename ON metadata_and_text(filename) CASCADE - # */ - #}) + 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 |