diff --git a/src/onedb/database_schema.rb b/src/onedb/database_schema.rb index c80f490a0c..71b135e859 100644 --- a/src/onedb/database_schema.rb +++ b/src/onedb/database_schema.rb @@ -187,15 +187,4 @@ class OneDBBacKEnd @db.run sql end - def create_idx(type, version = nil) - - schema = get_schema(type, version) - - schema.each do |idx| - @db.run idx - end - - end - end - diff --git a/src/onedb/local/5.6.0_to_5.7.80.rb b/src/onedb/local/5.6.0_to_5.7.80.rb index 121ecefcf5..1b28464c69 100644 --- a/src/onedb/local/5.6.0_to_5.7.80.rb +++ b/src/onedb/local/5.6.0_to_5.7.80.rb @@ -38,12 +38,11 @@ module Migrator def up feature_2944 - bug_2687 # MUST be run before 2489, which generates short body + bug_2687 # MUST be run before 2489, which generates short body feature_2253 feature_2489_2671 feature_826 feature_2966 - create_idxs #MUST be the last one true end @@ -275,18 +274,6 @@ module Migrator return str_scaped end - def is_fts_available() - if @db.adapter_scheme == :sqlite - return false - else - if @db.server_version >= 50600 - return true - else - return false - end - end - end - def gen_short_body(body) short_body = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.VM{ @@ -473,14 +460,6 @@ module Migrator @db.run "DROP TABLE old_vm_pool;" end - def create_idxs - if !is_fts_available - create_idx(:index_sqlite, db_version) - else - create_idx(:index_sql, db_version) - end - end - def feature_2966 @db.run "ALTER TABLE logdb ADD applied BOOLEAN DEFAULT 1;" @db.run "UPDATE logdb SET applied = 0 WHERE timestamp = 0;" diff --git a/src/onedb/onedb.rb b/src/onedb/onedb.rb index 023e215a77..a1c6939ea4 100644 --- a/src/onedb/onedb.rb +++ b/src/onedb/onedb.rb @@ -186,6 +186,9 @@ class OneDB puts "Database already uses version #{db_version[:local_version]}" end + # Generate indexes + @backend.create_idx + timeb = Time.now puts diff --git a/src/onedb/onedb_backend.rb b/src/onedb/onedb_backend.rb index ce89b8e9e0..c491afce4e 100644 --- a/src/onedb/onedb_backend.rb +++ b/src/onedb/onedb_backend.rb @@ -413,6 +413,18 @@ class BackEndMySQL < OneDBBacKEnd end end + def create_idx(version = nil) + type = :index_sql + + type = :index_sqlite unless @db.server_version >= 50600 + + schema = get_schema(type, version) + + schema.each do |idx| + @db.run idx + end + end + private def connect_db @@ -541,6 +553,16 @@ class BackEndSQLite < OneDBBacKEnd puts "Sqlite database backup restored in #{@sqlite_file}" end + def create_idx(version = nil) + type = :index_sqlite + + schema = get_schema(type, version) + + schema.each do |idx| + @db.run idx + end + end + private def connect_db