Sha256: a62928a899436c5f318f87b0f0a60e6880de378d4717304e2928dc2e1df073d6

Contents?: true

Size: 1.09 KB

Versions: 16

Compression:

Stored size: 1.09 KB

Contents

class RemoveIndexes < ActiveRecord::Migration[5.1]

  def change
    remove_index :packet_log_entries, :is_tlm
    remove_index :packet_log_entries, :target_id
    remove_index :packet_log_entries, :meta_id
    remove_index :packet_log_entries, :ready
    remove_index :packet_log_entries, :packet_id
    remove_index :packet_log_entries, :packet_log_id

    ActiveRecord::Base.connection.tables.each do |table|
      # Since the decommutation tables are created dynamically we search
      # through all the tables looking for tables named something like
      # tXXX_YYY where XXX is the PacketConfig ID and YYY is the table index
      if table.to_s =~ /^t(\d+)_(\d+)$/ # ASCII art? No! Regex!
        packet_config_id = $1.to_i
        table_index = $2.to_i

        ["", "_m", "_h", "_d"].each do |modifier|
          table_name = table + modifier
          remove_index table_name, :meta_id
          remove_index table_name, :reduced_id
          remove_index table_name, :reduced_state
          add_index table_name, :reduced_state, :where => "reduced_state < 2"
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cosmos-4.5.2-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.5.2 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.5.1-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.5.1 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.5.0-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.5.0 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.4.2-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.4.2 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.4.1-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.4.1 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.4.0-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.4.0 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.3.0-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.3.0 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.2.4-java lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb
cosmos-4.2.4 lib/cosmos/dart/db/migrate/20180509204705_remove_indexes.rb