local addonName, Cell = ...
local L = Cell.L
local F = Cell.funcs
local I = Cell.iFuncs

function F:Revise()
    local dbRevision = CellDB["revise"] and tonumber(string.match(CellDB["revise"], "%d+")) or 0
    F:Debug("DBRevision:", dbRevision)

    local charaDbRevision
    if Cell.isVanilla or Cell.isWrath then
        charaDbRevision = CellCharacterDB["revise"] and tonumber(string.match(CellCharacterDB["revise"], "%d+")) or 0
        F:Debug("CharaDBRevision:", charaDbRevision)
    end

    if CellDB["revise"] and dbRevision < Cell.MIN_VERSION then -- update from an unsupported version
        local f = CreateFrame("Frame")
        f:RegisterEvent("PLAYER_ENTERING_WORLD")
        f:SetScript("OnEvent", function()
            f:UnregisterAllEvents()
            local popup = Cell:CreateConfirmPopup(CellAnchorFrame, 260, L["RESET"].."\n"..L["RESET_YES_NO"], function()
                CellDB = nil
                CellCharacterDB = nil
                ReloadUI()
            end)
            popup:SetPoint("TOPLEFT")
        end)
        return
    end
    
    if CellCharacterDB and CellCharacterDB["revise"] and charaDbRevision < Cell.MIN_VERSION then -- update from an unsupported version
        local f = CreateFrame("Frame")
        f:RegisterEvent("PLAYER_ENTERING_WORLD")
        f:SetScript("OnEvent", function()
            f:UnregisterAllEvents()
            local popup = Cell:CreateConfirmPopup(CellAnchorFrame, 260, L["RESET_CHARACTER"].."\n|cFFB7B7B7"..L["RESET_INCLUDES"].."|r\n"..L["RESET_YES_NO"], function()
                CellCharacterDB = nil
                ReloadUI()
            end)
            popup:SetPoint("TOPLEFT")
        end)
        return
    end

    --[=[
    -- r4-alpha add "castByMe"
    if not(CellDB["revise"]) or CellDB["revise"] < "r4-alpha" then
        for _, layout in pairs(CellDB["layouts"]) do
            for _, indicator in pairs(layout["indicators"]) do
                if indicator["auraType"] == "buff" then
                    if indicator["castByMe"] == nil then
                        indicator["castByMe"] = true
                    end
                elseif indicator["indicatorName"] == "dispels" then
                    if indicator["checkbutton"] then
                        indicator["dispellableByMe"] = indicator["checkbutton"][2]
                        indicator["checkbutton"] = nil
                    end
                end
            end
        end
    end

    -- r6-alpha
    if not(CellDB["revise"]) or CellDB["revise"] < "r6-alpha" then
        -- add "textWidth"
        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["textWidth"] then
                layout["textWidth"] = 0.75
            end
        end
        -- remove old raid tools related
        if CellDB["showRaidSetup"] then CellDB["showRaidSetup"] = nil end
        if CellDB["pullTimer"] then CellDB["pullTimer"] = nil end
    end

    -- r13-release: fix all
    if not(CellDB["revise"]) or dbRevision < 13 then
        -- r8-beta: add "centralDebuff"
        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["indicators"][8] or layout["indicators"][8]["indicatorName"] ~= "centralDebuff" then
                tinsert(layout["indicators"], 8, {
                    ["name"] = "Central Debuff",
                    ["indicatorName"] = "centralDebuff",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"CENTER", "CENTER", 0, 3},
                    ["size"] = {20, 20},
                    ["font"] = {"Cell ".._G.DEFAULT, 11, "Outline", 2},
                })
            end
        end

        -- r9-beta: fix raidtool db
        if type(CellDB["raidTools"]["showBattleRes"]) ~= "boolean" then CellDB["raidTools"]["showBattleRes"] = true end
        if not CellDB["raidTools"]["buttonsPosition"] then CellDB["raidTools"]["buttonsPosition"] = {"TOPRIGHT", "CENTER", 0, 0} end
        if not CellDB["raidTools"]["marksPosition"] then CellDB["raidTools"]["marksPosition"] = {"BOTTOMRIGHT", "CENTER", 0, 0} end

        -- r11-release: add horizontal layout
        for _, layout in pairs(CellDB["layouts"]) do
            if type(layout["orientation"]) ~= "string" then
                layout["orientation"] = "vertical"
            end
        end

        -- r13 release: CellDB["appearance"]
        if CellDB["texture"] then CellDB["appearance"]["texture"] = CellDB["texture"] end
        if CellDB["scale"] then CellDB["appearance"]["scale"] = CellDB["scale"] end
        if CellDB["font"] then CellDB["appearance"]["font"] = CellDB["font"] end
        if CellDB["outline"] then CellDB["appearance"]["outline"] = CellDB["outline"] end
        CellDB["texture"] = nil
        CellDB["scale"] = nil
        CellDB["font"] = nil
        CellDB["outline"] = nil
    end

    -- r14-release: CellDB["general"]
    if not(CellDB["revise"]) or dbRevision < 14 then
        if CellDB["hideBlizzard"] then CellDB["general"]["hideBlizzard"] = CellDB["hideBlizzard"] end
        if CellDB["disableTooltips"] then CellDB["general"]["disableTooltips"] = CellDB["disableTooltips"] end
        if CellDB["showSolo"] then CellDB["general"]["showSolo"] = CellDB["showSolo"] end
        CellDB["hideBlizzard"] = nil
        CellDB["disableTooltips"] = nil
        CellDB["showSolo"] = nil
    end
    
    -- r15-release
    if not(CellDB["revise"]) or dbRevision < 15 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- add powerHeight
            if type(layout["powerHeight"]) ~= "number" then
                layout["powerHeight"] = 2
            end
            -- add dispel highlight
            if layout["indicators"][6] and layout["indicators"][6]["indicatorName"] == "dispels" then
                if type(layout["indicators"][6]["enableHighlight"]) ~= "boolean" then
                    layout["indicators"][6]["enableHighlight"] = true
                end
            end
        end
        -- change showPets to showPartyPets
        if type(CellDB["general"]["showPartyPets"]) ~= "boolean" then
            CellDB["general"]["showPartyPets"] = CellDB["general"]["showPets"]
            CellDB["general"]["showPets"] = nil
        end
    end

    -- r22-release
    if not(CellDB["revise"]) or dbRevision < 22 then
        -- highlight color
        if not CellDB["appearance"]["targetColor"] then CellDB["appearance"]["targetColor"] = {1, 0.19, 0.19, 0.5} end
        if not CellDB["appearance"]["mouseoverColor"] then CellDB["appearance"]["mouseoverColor"] = {1, 1, 1, 0.5} end
        for _, layout in pairs(CellDB["layouts"]) do
            -- columns/rows
            if type(layout["columns"]) ~= "number" then layout["columns"] = 8 end
            if type(layout["rows"]) ~= "number" then layout["rows"] = 8 end
            if type(layout["groupSpacing"]) ~= "number" then layout["groupSpacing"] = 0 end
            -- targetMarker
            -- if layout["indicators"][1] and layout["indicators"][1]["indicatorName"] ~= "targetMarker" then
            -- 	tinsert(layout["indicators"], 1, {
            -- 		["name"] = "Target Marker",
            -- 		["indicatorName"] = "targetMarker",
            -- 		["type"] = "built-in",
            -- 		["enabled"] = true,
            -- 		["position"] = {"TOP", "TOP", 0, 3},
            -- 		["size"] = {14, 14},
            -- 		["alpha"] = 0.77,
            -- 	})
            -- end
        end
    end

    -- r23-release
    if not(CellDB["revise"]) or dbRevision < 23 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- rename targetMarker to playerRaidIcon
            if layout["indicators"][1] then
                if layout["indicators"][1]["indicatorName"] == "targetMarker" then -- r22
                    layout["indicators"][1]["name"] = "Raid Icon (player)"
                    layout["indicators"][1]["indicatorName"] = "playerRaidIcon"
                elseif layout["indicators"][1]["indicatorName"] == "aggroBar" then
                    tinsert(layout["indicators"], 1, {
                        ["name"] = "Raid Icon (player)",
                        ["indicatorName"] = "playerRaidIcon",
                        ["type"] = "built-in",
                        ["enabled"] = true,
                        ["position"] = {"TOP", "TOP", 0, 3},
                        ["size"] = {14, 14},
                        ["alpha"] = 0.77,
                    })
                end
            end
            if layout["indicators"][2] and layout["indicators"][2]["indicatorName"] ~= "targetRaidIcon" then
                tinsert(layout["indicators"], 2, {
                    ["name"] = "Raid Icon (target)",
                    ["indicatorName"] = "targetRaidIcon",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"TOP", "TOP", -14, 3},
                    ["size"] = {14, 14},
                    ["alpha"] = 0.77,
                })
            end
        end
    end

    -- r25-release
    if not(CellDB["revise"]) or dbRevision < 25 then
        -- position for raidTools
        if #CellDB["raidTools"]["marksPosition"] == 4 then CellDB["raidTools"]["marksPosition"] = {} end
        if #CellDB["raidTools"]["buttonsPosition"] == 4 then CellDB["raidTools"]["buttonsPosition"] = {} end
        -- position & anchor for layouts
        for _, layout in pairs(CellDB["layouts"]) do
            if type(layout["position"]) ~= "table" then
                layout["position"] = {}
            end
            if type(layout["anchor"]) ~= "string" then
                layout["anchor"] = "TOPLEFT"
            end
        end
        -- reset CellDB["debuffBlacklist"]
        CellDB["debuffBlacklist"] = I:GetDefaultDebuffBlacklist()
        -- update click-castings
        -- self:SetBindingClick(true, "MOUSEWHEELUP", self, "Button6")
        -- self:SetBindingClick(true, "SHIFT-MOUSEWHEELUP", self, "Button7")
        -- self:SetBindingClick(true, "CTRL-MOUSEWHEELUP", self, "Button8")
        -- self:SetBindingClick(true, "ALT-MOUSEWHEELUP", self, "Button9")
        -- self:SetBindingClick(true, "CTRL-SHIFT-MOUSEWHEELUP", self, "Button10")
        -- self:SetBindingClick(true, "ALT-SHIFT-MOUSEWHEELUP", self, "Button11")
        -- self:SetBindingClick(true, "ALT-CTRL-MOUSEWHEELUP", self, "Button12")
        -- self:SetBindingClick(true, "ALT-CTRL-SHIFT-MOUSEWHEELUP", self, "Button13")

        -- self:SetBindingClick(true, "MOUSEWHEELDOWN", self, "Button14")
        -- self:SetBindingClick(true, "SHIFT-MOUSEWHEELDOWN", self, "Button15")
        -- self:SetBindingClick(true, "CTRL-MOUSEWHEELDOWN", self, "Button16")
        -- self:SetBindingClick(true, "ALT-MOUSEWHEELDOWN", self, "Button17")
        -- self:SetBindingClick(true, "CTRL-SHIFT-MOUSEWHEELDOWN", self, "Button18")
        -- self:SetBindingClick(true, "ALT-SHIFT-MOUSEWHEELDOWN", self, "Button19")
        -- self:SetBindingClick(true, "ALT-CTRL-MOUSEWHEELDOWN", self, "Button20")
        -- self:SetBindingClick(true, "ALT-CTRL-SHIFT-MOUSEWHEELDOWN", self, "Button21")
        local replacements = {
            [6] = "type-SCROLLUP",
            [7] = "shift-type-SCROLLUP",
            [8] = "ctrl-type-SCROLLUP",
            [9] = "alt-type-SCROLLUP",
            [10] = "ctrl-shift-type-SCROLLUP",
            [11] = "alt-shift-type-SCROLLUP",
            [12] = "alt-ctrl-type-SCROLLUP",
            [13] = "alt-ctrl-shift-type-SCROLLUP",

            [14] = "type-SCROLLDOWN",
            [15] = "shift-type-SCROLLDOWN",
            [16] = "ctrl-type-SCROLLDOWN",
            [17] = "alt-type-SCROLLDOWN",
            [18] = "ctrl-shift-type-SCROLLDOWN",
            [19] = "alt-shift-type-SCROLLDOWN",
            [20] = "alt-ctrl-type-SCROLLDOWN",
            [21] = "alt-ctrl-shift-type-SCROLLDOWN",
        }
        for class, classTable in pairs(CellDB["clickCastings"]) do
            for spec, specTable in pairs(classTable) do
                if type(specTable) == "table" then -- not "useCommon"
                    for _, clickCastingTable in pairs(specTable) do
                        local keyID = tonumber(strmatch(clickCastingTable[1], "%d+"))
                        if keyID and keyID > 5 then
                            clickCastingTable[1] = replacements[keyID]
                        end
                    end
                end
            end
        end
    end

    -- r29-release
    if not(CellDB["revise"]) or dbRevision < 29 then
        for _, layout in pairs(CellDB["layouts"]) do
            for _, indicator in pairs(layout["indicators"]) do
                if indicator["type"] == "built-in" then
                    if indicator["indicatorName"] == "playerRaidIcon" then
                        indicator["frameLevel"] = 1
                    elseif indicator["indicatorName"] == "targetRaidIcon" then
                        indicator["frameLevel"] = 1
                    elseif indicator["indicatorName"] == "aggroBar" then
                        indicator["frameLevel"] = 1
                    elseif indicator["indicatorName"] == "externalCooldowns" then
                        indicator["frameLevel"] = 10
                    elseif indicator["indicatorName"] == "defensiveCooldowns" then
                        indicator["frameLevel"] = 10
                    elseif indicator["indicatorName"] == "tankActiveMitigation" then
                        indicator["frameLevel"] = 1
                    elseif indicator["indicatorName"] == "dispels" then
                        indicator["frameLevel"] = 15
                    elseif indicator["indicatorName"] == "debuffs" then
                        indicator["frameLevel"] = 1
                    elseif indicator["indicatorName"] == "centralDebuff" then
                        indicator["frameLevel"] = 20
                    end
                else
                    indicator["frameLevel"] = 5
                end
            end
        end
    end

    -- r33-release
    if CellDB["revise"] and dbRevision < 33 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- move health text
            local healthTextIndicator
            if layout["indicators"][11] and layout["indicators"][11]["indicatorName"] == "healthText" then
                healthTextIndicator = F:Copy(layout["indicators"][11])
                layout["indicators"][11] = nil
            else
                healthTextIndicator = {
                    ["name"] = "Health Text",
                    ["indicatorName"] = "healthText",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"TOP", "CENTER", 0, -5},
                    ["frameLevel"] = 1,
                    ["font"] = {"Cell ".._G.DEFAULT, 10, "Shadow", 0},
                    ["color"] = {1, 1, 1},
                    ["format"] = "percentage",
                    ["hideFull"] = true,
                }
            end

            -- add new
            if layout["indicators"][1]["indicatorName"] ~= "healthText" then
                tinsert(layout["indicators"], 1, healthTextIndicator)
                tinsert(layout["indicators"], 2, {
                    ["name"] = "Role Icon",
                    ["indicatorName"] = "roleIcon",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"TOPLEFT", "TOPLEFT", 0, 0},
                    ["size"] = {11, 11},
                })
                tinsert(layout["indicators"], 3, {
                    ["name"] = "Leader Icon",
                    ["indicatorName"] = "leaderIcon",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"TOPLEFT", "TOPLEFT", 0, -11},
                    ["size"] = {11, 11},
                })
                tinsert(layout["indicators"], 4, {
                    ["name"] = "Ready Check Icon",
                    ["indicatorName"] = "readyCheckIcon",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["frameLevel"] = 100,
                    ["size"] = {16, 16},
                })
                tinsert(layout["indicators"], 7, {
                    ["name"] = "Aggro Indicator",
                    ["indicatorName"] = "aggroIndicator",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"TOPLEFT", "TOPLEFT", 0, 0},
                    ["frameLevel"] = 2,
                    ["size"] = {10, 10},
                })
            end

            -- update centralDebuff border
            if layout["indicators"][15] and layout["indicators"][15]["indicatorName"] == "centralDebuff" then
                if not layout["indicators"][15]["border"] then
                    layout["indicators"][15]["border"] = 2
                    if layout["indicators"][15]["size"][1] == 20 then
                        layout["indicators"][15]["size"] = {22, 22}
                    end
                end
                if type(layout["indicators"][15]["onlyShowTopGlow"]) ~= "boolean" then
                    layout["indicators"][15]["onlyShowTopGlow"] = true
                end
            end
        end

        if not F:TContains(CellDB["debuffBlacklist"], 160029) then
            tinsert(CellDB["debuffBlacklist"], 2, 160029)
        end

        -- glow options for raidDebuffs
        for instance, iTable in pairs(CellDB["raidDebuffs"]) do
            for boss, bTable in pairs(iTable) do
                for spell, sTable in pairs(bTable) do
                    if type(sTable[2]) ~= "boolean" then
                        tinsert(sTable, 2, false)
                    end
                    if sTable[3] and sTable[4] and type(sTable[4][1]) == "number" then
                        local color = {sTable[4][1], sTable[4][2], sTable[4][3], 1}
                        if sTable[3] == "None" or sTable[3] == "Normal" then
                            sTable[4] = {color}
                        elseif sTable[3] == "Pixel" then
                            sTable[4] = {color, 9, 0.25, 8, 2}
                        elseif sTable[3] == "Shine" then
                            sTable[4] = {color, 9, 0.5, 1}
                        end
                    end
                end
            end
        end

        -- options ui font size
        if not CellDB["appearance"]["optionsFontSizeOffset"] then
            CellDB["appearance"]["optionsFontSizeOffset"] = 0
        end

        -- tooltips
        if type(CellDB["general"]["disableTooltips"]) == "boolean" then
            CellDB["general"]["enableTooltips"] = not CellDB["general"]["disableTooltips"]
            CellDB["general"]["disableTooltips"] = nil
        end
    end

    -- r36-release
    if CellDB["revise"] and dbRevision < 36 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- rename Central Debuff
            if layout["indicators"][15] and layout["indicators"][15]["indicatorName"] == "centralDebuff" then
                layout["indicators"][15]["indicatorName"] = "raidDebuffs"
                layout["indicators"][15]["name"] = "Raid Debuffs"
            end

            -- add Name Text
            if layout["indicators"][1]["indicatorName"] ~= "nameText" then
                tinsert(layout["indicators"], 1, {
                    ["name"] = "Name Text",
                    ["indicatorName"] = "nameText",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"CENTER", "CENTER", 0, 0},
                    ["font"] = {"Cell ".._G.DEFAULT, 13, "Shadow"},
                    ["nameColor"] = {"Custom Color", {1, 1, 1}},
                    ["vehicleNamePosition"] = {"TOP", 0},
                    ["textWidth"] = 0.75,
                })
            end

            -- add Status Text
            if layout["indicators"][2]["indicatorName"] ~= "statusText" then
                tinsert(layout["indicators"], 2, {
                    ["name"] = "Status Text",
                    ["indicatorName"] = "statusText",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"BOTTOM", 0},
                    ["frameLevel"] = 30,
                    ["font"] = {"Cell ".._G.DEFAULT, 11, "Shadow"},
                })
            end

            -- add Shiled Bar
            if layout["indicators"][11]["indicatorName"] ~= "shieldBar" then
                tinsert(layout["indicators"], 11, {
                    ["name"] = "Shield Bar",
                    ["indicatorName"] = "shieldBar",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"BOTTOMLEFT", "BOTTOMLEFT", 0, 0},
                    ["frameLevel"] = 1,
                    ["height"] = 4,
                    ["color"] = {1, 1, 0, 1},
                })
            end
        end
    end

    -- r37-release
    if CellDB["revise"] and dbRevision < 37 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- useCustomTexture
            if layout["indicators"][4] and layout["indicators"][4]["indicatorName"] == "roleIcon" then
                if type(layout["indicators"][4]["customTextures"]) ~= "table" then
                    layout["indicators"][4]["customTextures"] = {false, "Interface\\AddOns\\ElvUI\\Media\\Textures\\Tank.tga", "Interface\\AddOns\\ElvUI\\Media\\Textures\\Healer.tga", "Interface\\AddOns\\ElvUI\\Media\\Textures\\DPS.tga"}
                end
            end
        end
    end
    
    -- r38-release
    if CellDB["revise"] and dbRevision < 38 then
        if CellDB["raidTools"]["pullTimer"][1] == "ERT" then
            CellDB["raidTools"]["pullTimer"][1] = "ExRT"
        end

        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["indicators"][19] or layout["indicators"][19]["indicatorName"] ~= "targetedSpells" then
                tinsert(layout["indicators"], 19, {
                    ["name"] = "Targeted Spells",
                    ["indicatorName"] = "targetedSpells",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"CENTER", "TOPLEFT", 7, -7},
                    ["frameLevel"] = 50,
                    ["size"] = {20, 20},
                    ["border"] = 2,
                    ["spells"] = {},
                    ["glow"] = {"Pixel", {0.95,0.95,0.32,1}, 9, 0.25, 8, 2},
                    ["font"] = {"Cell ".._G.DEFAULT, 12, "Outline", 2},
                })
            end
        end
    end

    -- r41-release
    if CellDB["revise"] and dbRevision < 41 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "targetedSpells" then
                if #layout["indicators"][19]["spells"] == 0 then
                    layout["indicators"][19]["enabled"] = true
                    layout["indicators"][19]["spells"] = {320788, 344496, 319941}
                end
            end
        end
    end

    -- r44-release
    if CellDB["revise"] and dbRevision < 44 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][19]["spells"], 320132) then -- 暗影之怒
                    tinsert(layout["indicators"][19]["spells"], 320132)
                end
                if not F:TContains(layout["indicators"][19]["spells"], 322614) then -- 心灵连接
                    tinsert(layout["indicators"][19]["spells"], 322614)
                end
            end
        end
    end

    -- r46-release
    if CellDB["revise"] and dbRevision < 46 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][13] and layout["indicators"][13]["indicatorName"] == "externalCooldowns" then
                layout["indicators"][13]["orientation"] = "right-to-left"
            end
            if layout["indicators"][14] and layout["indicators"][14]["indicatorName"] == "defensiveCooldowns" then
                layout["indicators"][14]["orientation"] = "left-to-right"
            end
            if layout["indicators"][17] and layout["indicators"][17]["indicatorName"] == "debuffs" then
                layout["indicators"][17]["orientation"] = "left-to-right"
            end
        end

        CellDB["general"]["tooltipsPosition"] = {"BOTTOMLEFT", "Unit Button", "TOPLEFT", 0, 15}
    end

    -- r47-release
    if CellDB["revise"] and dbRevision < 47 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][19]["spells"], 334053) then -- 净化冲击波
                    tinsert(layout["indicators"][19]["spells"], 334053)
                end
            end
        end

        if type(CellDB["appearance"]["highlightSize"]) ~= "number" then
            CellDB["appearance"]["highlightSize"] = 1
        end
        if type(CellDB["appearance"]["outOfRangeAlpha"]) ~= "number" then
            CellDB["appearance"]["outOfRangeAlpha"] = 0.45
        end
    end

    -- r48-release
    if CellDB["revise"] and dbRevision < 48 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][19]["spells"], 343556) then -- 病态凝视
                    tinsert(layout["indicators"][19]["spells"], 343556)
                end
                if not F:TContains(layout["indicators"][19]["spells"], 320596) then -- 深重呕吐
                    tinsert(layout["indicators"][19]["spells"], 320596)
                end
            end
        end
    end

    -- r49-release
    if CellDB["revise"] and dbRevision < 49 then
        if type(CellDB["appearance"]["barAnimation"]) ~= "string" then
            CellDB["appearance"]["barAnimation"] = "Flash"
        end
    end

    -- r50-release
    if CellDB["revise"] and dbRevision < 50 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- add statusIcon
            if layout["indicators"][4] and layout["indicators"][4]["indicatorName"] ~= "statusIcon" then
                tinsert(layout["indicators"], 4, {
                    ["name"] = "Status Icon",
                    ["indicatorName"] = "statusIcon",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["position"] = {"TOP", "TOP", 0, -3},
                    ["frameLevel"] = 10,
                    ["size"] = {18, 18},
                })
            end

            -- update debuffs
            if layout["indicators"][18] and layout["indicators"][18]["indicatorName"] == "debuffs" then
                if type(layout["indicators"][18]["bigDebuffs"]) ~= "table" then
                    layout["indicators"][18]["bigDebuffs"] = {
                        209858, -- 死疽溃烂
                        46392, -- 专注打击
                    }
                    layout["indicators"][18]["size"] = {layout["indicators"][18]["size"], {17, 17}} -- normalSize, bigSize
                end
            end

            -- add targetCounter
            if (not layout["indicators"][21]) or (layout["indicators"][21] and layout["indicators"][21]["indicatorName"] ~= "targetCounter") then
                tinsert(layout["indicators"], 21, {
                    ["name"] = "Target Counter",
                    ["indicatorName"] = "targetCounter",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"TOP", "TOP", 0, 5},
                    ["frameLevel"] = 15,
                    ["font"] = {"Cell ".._G.DEFAULT, 15, "Outline", 0},
                    ["color"] = {1, 0.1, 0.1},
                })
            end
        end
    end

    -- r55-release
    if CellDB["revise"] and dbRevision < 55 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- update debuffs
            if layout["indicators"][18] and layout["indicators"][18]["indicatorName"] == "debuffs" then
                --- 焚化者阿寇拉斯
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 355732) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 355732) -- 融化灵魂
                end
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 355738) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 355738) -- 灼热爆破
                end
                -- 凇心之欧罗斯
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 356667) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 356667) -- 刺骨之寒
                end
                -- 刽子手瓦卢斯
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 356925) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 356925) -- 屠戮
                end
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 356923) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 356923) -- 撕裂
                end
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 358973) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 358973) -- 恐惧浪潮
                end
                -- 粉碎者索苟冬
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 355806) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 355806) -- 重压
                end
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 358777) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 358777) -- 痛苦之链
                end
            end
        end
    end

    -- r56-release
    if CellDB["revise"] and dbRevision < 56 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][20] and layout["indicators"][20]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][20]["spells"], 356924) then
                    tinsert(layout["indicators"][20]["spells"], 356924)  -- 屠戮
                end
                if not F:TContains(layout["indicators"][20]["spells"], 356666) then -- 刺骨之寒
                    tinsert(layout["indicators"][20]["spells"], 356666)
                end
                if not F:TContains(layout["indicators"][20]["spells"], 319713) then -- 巨兽奔袭
                    tinsert(layout["indicators"][20]["spells"], 319713)
                end
            end
            if layout["indicators"][18] and layout["indicators"][18]["indicatorName"] == "debuffs" then
                if not F:TContains(layout["indicators"][18]["bigDebuffs"], 240559) then
                    tinsert(layout["indicators"][18]["bigDebuffs"], 240559)  -- 重伤
                end
            end
        end
    end

    -- r57-release
    if CellDB["revise"] and dbRevision < 57 then
        if type(CellDB["raidTools"]["deathReport"]) ~= "table" then
            CellDB["raidTools"]["deathReport"] = {false, 10}
        end
        if type(CellDB["raidTools"]["showBuffTracker"]) ~= "boolean" then
            CellDB["raidTools"]["showBuffTracker"] = false
        end
        if type(CellDB["raidTools"]["buffTrackerPosition"]) ~= "table" then
            CellDB["raidTools"]["buffTrackerPosition"] = {}
        end
    end

    -- r60-release
    if CellDB["revise"] and dbRevision < 60 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][20] and layout["indicators"][20]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][20]["spells"], 338606) then
                    tinsert(layout["indicators"][20]["spells"], 338606) -- 病态凝视
                end
                if not F:TContains(layout["indicators"][20]["spells"], 343556) then
                    tinsert(layout["indicators"][20]["spells"], 343556) -- 病态凝视
                end
            end
            if type(layout["petSize"]) ~= "table" then
                layout["petSize"] = {false, 66, 46}
            end
        end
    end

    -- r61-release
    if CellDB["revise"] and dbRevision < 61 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- rename aggroIndicator
            if layout["indicators"][10] and layout["indicators"][10]["indicatorName"] == "aggroIndicator" then
                layout["indicators"][10]["name"] = "Aggro (blink)"
                layout["indicators"][10]["indicatorName"] = "aggroBlink"
            end
            -- rename aggroBar
            if layout["indicators"][11] and layout["indicators"][11]["indicatorName"] == "aggroBar" then
                layout["indicators"][11]["name"] = "Aggro (bar)"
            end
            -- add aggroBorder
            if layout["indicators"][12] and layout["indicators"][12]["indicatorName"] ~= "aggroBorder" then
                tinsert(layout["indicators"], 12, {
                    ["name"] = "Aggro (border)",
                    ["indicatorName"] = "aggroBorder",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["frameLevel"] = 1,
                    ["thickness"] = 3,
                })
            end
            -- update frameLevel
            for _, indicator in pairs(layout["indicators"]) do
                if indicator["indicatorName"] == "healthText" then
                    indicator["frameLevel"] = 2
                elseif indicator["indicatorName"] == "playerRaidIcon" then
                    indicator["frameLevel"] = 2
                elseif indicator["indicatorName"] == "targetRaidIcon" then
                    indicator["frameLevel"] = 2
                elseif indicator["indicatorName"] == "aggroBlink" then
                    indicator["frameLevel"] = 3
                elseif indicator["indicatorName"] == "shieldBar" then
                    indicator["frameLevel"] = 2
                elseif indicator["indicatorName"] == "tankActiveMitigation" then
                    indicator["frameLevel"] = 2
                elseif indicator["indicatorName"] == "debuffs" then
                    indicator["frameLevel"] = 2
                end
            end
        end
    end

    -- r63-release
    if CellDB["revise"] and dbRevision < 63 then
        -- 起伏机动
        if not F:TContains(CellDB["debuffBlacklist"], 352562) then
            tinsert(CellDB["debuffBlacklist"], 352562)
            Cell.vars.debuffBlacklist = F:ConvertTable(CellDB["debuffBlacklist"])
        end
    end
    
    -- r64-release
    if CellDB["revise"] and dbRevision < 64 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][21] and layout["indicators"][21]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][21]["spells"], 324079) then
                    tinsert(layout["indicators"][21]["spells"], 324079) -- 收割之镰
                end
                if not F:TContains(layout["indicators"][21]["spells"], 317963) then
                    tinsert(layout["indicators"][21]["spells"], 317963) -- 知识烦扰
                end
            end
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "debuffs" then
                if not F:TContains(layout["indicators"][19]["bigDebuffs"], 240443) then
                    tinsert(layout["indicators"][19]["bigDebuffs"], 240443) -- 爆裂
                end
                if F:TContains(layout["indicators"][19]["bigDebuffs"], 243237) then
                    F:TRemove(layout["indicators"][19]["bigDebuffs"], 243237)
                end
            end
        end
        -- 审判灵魂
        if not F:TContains(CellDB["debuffBlacklist"], 356419) then
            tinsert(CellDB["debuffBlacklist"], 356419)
            Cell.vars.debuffBlacklist = F:ConvertTable(CellDB["debuffBlacklist"])
        end
    end

    -- r65-release
    if CellDB["revise"] and dbRevision < 65 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][21] and layout["indicators"][21]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][21]["spells"], 333861) then
                    tinsert(layout["indicators"][21]["spells"], 333861) -- 回旋利刃
                end
            end
        end
    end

    -- r66-release
    if CellDB["revise"] and dbRevision < 66 then
        -- always targeting
        if not CellDB["clickCastings"][Cell.vars.playerClass]["alwaysTargeting"] then
            CellDB["clickCastings"][Cell.vars.playerClass]["alwaysTargeting"] = {
                ["common"] = "disabled",
            }
            for sepcIndex = 1, GetNumSpecializationsForClassID(Cell.vars.playerClassID) do
                local specID = GetSpecializationInfoForClassID(Cell.vars.playerClassID, sepcIndex)
                CellDB["clickCastings"][Cell.vars.playerClass]["alwaysTargeting"][specID] = "disabled"
            end
        end
    end

    -- r68-release
    if CellDB["revise"] and dbRevision < 68 then
        if type(CellDB["appearance"]["iconAnimation"]) ~= "string" then
            CellDB["appearance"]["iconAnimation"] = "duration"
        end
    end
    
    -- r69-release
    if CellDB["revise"] and dbRevision < 69 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][20] and layout["indicators"][20]["indicatorName"] == "raidDebuffs" then
                layout["indicators"][20]["num"] = 1
                layout["indicators"][20]["orientation"] = "left-to-right"
            end
        end

        if type(CellDB["appearance"]["bgAlpha"]) ~= "number" then
            CellDB["appearance"]["bgAlpha"] = 1
        end
    end

    -- r70-release
    if CellDB["revise"] and dbRevision < 70 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- check custom indicator
            for i = 23, #layout["indicators"] do
                if layout["indicators"][i]["type"] == "text" then
                    layout["indicators"][i]["showDuration"] = true
                end
            end
        end

        if type(CellDB["appearance"]["barAlpha"]) ~= "number" then
            CellDB["appearance"]["barAlpha"] = 1
        end
        
        if type(CellDB["appearance"]["lossAlpha"]) ~= "number" then
            CellDB["appearance"]["lossAlpha"] = 1
        end

        if type(CellDB["appearance"]["lossColor"]) ~= "table" then
            CellDB["appearance"]["lossColor"] = CellDB["appearance"]["bgColor"]
            CellDB["appearance"]["bgColor"] = nil
        end 

        if type(CellDB["appearance"]["healPrediction"]) ~= "boolean" then
            CellDB["appearance"]["healPrediction"] = true
        end
        if type(CellDB["appearance"]["healAbsorb"]) ~= "boolean" then
            CellDB["appearance"]["healAbsorb"] = true
        end
        if type(CellDB["appearance"]["shield"]) ~= "boolean" then
            CellDB["appearance"]["shield"] = true
        end
        if type(CellDB["appearance"]["overshield"]) ~= "boolean" then
            CellDB["appearance"]["overshield"] = true
        end
    end

    -- r71-release
    if CellDB["revise"] and dbRevision < 71 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][2] and layout["indicators"][2]["indicatorName"] == "statusText" and not layout["indicators"][2]["colors"] then
                layout["indicators"][2]["colors"] = {
                    ["GHOST"] = {1, 0.19, 0.19},
                    ["DEAD"] = {1, 0.19, 0.19},
                    ["AFK"] = {1, 0.19, 0.19},
                    ["OFFLINE"] = {1, 0.19, 0.19},
                    ["FEIGN"] = {1, 1, 0.12},
                    ["DRINKING"] = {0.12, 0.75, 1},
                    ["PENDING"] = {1, 1, 0.12},
                    ["ACCEPTED"] = {0.12, 1, 0.12},
                    ["DECLINED"] = {1, 0.19, 0.19},
                }
            end
            
            if not layout["powerFilters"] then
                layout["powerFilters"] = {
                    ["DEATHKNIGHT"] = {["TANK"] = true, ["DAMAGER"] = true},
                    ["DEMONHUNTER"] = {["TANK"] = true, ["DAMAGER"] = true},
                    ["DRUID"] = {["TANK"] = true, ["DAMAGER"] = true, ["HEALER"] = true},
                    ["HUNTER"] = true,
                    ["MAGE"] = true,
                    ["MONK"] = {["TANK"] = true, ["DAMAGER"] = true, ["HEALER"] = true},
                    ["PALADIN"] = {["TANK"] = true, ["DAMAGER"] = true, ["HEALER"] = true},
                    ["PRIEST"] = {["DAMAGER"] = true, ["HEALER"] = true},
                    ["ROGUE"] = true,
                    ["SHAMAN"] = {["DAMAGER"] = true, ["HEALER"] = true},
                    ["WARLOCK"] = true,
                    ["WARRIOR"] = {["TANK"] = true, ["DAMAGER"] = true},
                    ["PET"] = true,
                    ["VEHICLE"] = true,
                    ["NPC"] = true,
                }
            end
        end
    end

    -- r74-release
    if CellDB["revise"] and dbRevision < 74 then
        --! add "Condition"
        for instance, iTable in pairs(CellDB["raidDebuffs"]) do
            for boss, bTable in pairs(iTable) do
                for spell, sTable in pairs(bTable) do
                    if type(sTable[3]) ~= "table" then
                        tinsert(sTable, 3, {"None"})
                    end
                end
            end
        end
    end

    -- r77-release
    if CellDB["revise"] and dbRevision < 77 then
        if type(CellDB["appearance"]["useGameFont"]) ~= "boolean" then
            CellDB["appearance"]["useGameFont"] = true
        end
    end
    
    -- r79-release
    if CellDB["revise"] and dbRevision < 79 then
        -- update name text width
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][1] and layout["indicators"][1]["indicatorName"] == "nameText" then
                if type(layout["indicators"][1]["textWidth"]) == "number" then
                    local oldWidth = layout["indicators"][1]["textWidth"]
                    if oldWidth == 0 then -- unlimited
                        layout["indicators"][1]["textWidth"] = "unlimited"
                    else
                        layout["indicators"][1]["textWidth"] = {"percentage", oldWidth}
                    end
                end
            end
        end
    end

    -- r80-release
    if CellDB["revise"] and dbRevision < 80 then
        -- update name text width
        for _, layout in pairs(CellDB["layouts"]) do
            if type(layout["npcAnchor"]) ~= "table" then
                layout["npcAnchor"] = {false, {}}
            end
        end
    end
    
    -- r81-release
    if CellDB["revise"] and dbRevision < 81 then
        -- update marks
        if type(CellDB["raidTools"]["marks"]) ~= "table" then
            local oldShowMarks = CellDB["raidTools"]["showMarks"]
            local oldMarks = CellDB["raidTools"]["marks"]
            CellDB["raidTools"]["marks"] = {oldShowMarks, oldMarks.."_h", CellDB["raidTools"]["marksPosition"]}
            -- remove old
            CellDB["raidTools"]["showMarks"] = nil
            CellDB["raidTools"]["marksPosition"] = nil
        end

        -- update buffTracker
        if type(CellDB["raidTools"]["buffTracker"]) ~= "table" then
            CellDB["raidTools"]["buffTracker"] = {CellDB["raidTools"]["showBuffTracker"], CellDB["raidTools"]["buffTrackerPosition"]}
            -- remove old
            CellDB["raidTools"]["showBuffTracker"] = nil
            CellDB["raidTools"]["buffTrackerPosition"] = nil
        end
        
        -- update readyAndPull
        if type(CellDB["raidTools"]["readyAndPull"]) ~= "table" then
            CellDB["raidTools"]["readyAndPull"] = {CellDB["raidTools"]["showButtons"], CellDB["raidTools"]["pullTimer"], CellDB["raidTools"]["buttonsPosition"]}
            -- remove old
            CellDB["raidTools"]["showButtons"] = nil
            CellDB["raidTools"]["pullTimer"] = nil
            CellDB["raidTools"]["buttonsPosition"] = nil
        end
    end
    
    -- r82-release
    if CellDB["revise"] and dbRevision < 82 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "debuffs" then
                if not F:TContains(layout["indicators"][19]["bigDebuffs"], 366297) then
                    tinsert(layout["indicators"][19]["bigDebuffs"], 366297) -- 解构
                end
                if not F:TContains(layout["indicators"][19]["bigDebuffs"], 366288) then
                    tinsert(layout["indicators"][19]["bigDebuffs"], 366288) -- 猛力砸击
                end
            end
        end
    end
    
    -- r87-release
    if CellDB["revise"] and dbRevision < 87 then
        -- rename raid tools
        if CellDB["raidTools"] then
            -- update readyAndPull
            if CellDB["raidTools"]["readyAndPull"] and type(CellDB["raidTools"]["readyAndPull"][2]) == "table" then
                if CellDB["raidTools"]["readyAndPull"][2][1] == "ExRT" then
                    CellDB["raidTools"]["readyAndPull"][2][1] = "mrt"
                elseif CellDB["raidTools"]["readyAndPull"][2][1] == "DBM" then
                    CellDB["raidTools"]["readyAndPull"][2][1] = "dbm"
                elseif CellDB["raidTools"]["readyAndPull"][2][1] == "BW" then
                    CellDB["raidTools"]["readyAndPull"][2][1] = "bw"
                end
            end

            CellDB["tools"] = CellDB["raidTools"]
            CellDB["raidTools"] = nil
        end

        for _, layout in pairs(CellDB["layouts"]) do
            -- add barOrientation to layout
            if type(layout["barOrientation"]) ~= "table" then
                layout["barOrientation"] = {"horizontal", false}
            end
            -- rename powerHeight to powerSize
            if type(layout["powerSize"]) ~= "number" then
                layout["powerSize"] = layout["powerHeight"]
                layout["powerHeight"] = nil
            end
            -- rname npcAnchor to friendlyNPC
            if type(layout["npc"]) ~= "table" then
                layout["npc"] = {true, layout["npcAnchor"][1], layout["npcAnchor"][2]}
                layout["npcAnchor"] = nil
            end
            -- add showDuration to external
            if layout["indicators"][15] and layout["indicators"][15]["indicatorName"] == "externalCooldowns" then
                layout["indicators"][15]["showDuration"] = false
                layout["indicators"][15]["font"] = {"Cell ".._G.DEFAULT, 11, "Outline", 2}
            end
            -- add showDuration to defensive
            if layout["indicators"][16] and layout["indicators"][16]["indicatorName"] == "defensiveCooldowns" then
                layout["indicators"][16]["showDuration"] = false
                layout["indicators"][16]["font"] = {"Cell ".._G.DEFAULT, 11, "Outline", 2}
            end
            -- add showDuration to debuffs
            if layout["indicators"][19] and layout["indicators"][19]["indicatorName"] == "debuffs" then
                layout["indicators"][19]["showDuration"] = false
            end
        end
    end

    -- r90-release
    if CellDB["revise"] and dbRevision < 90 then
        -- separate glows from tools
        CellDB["tools"]["spellRequest"] = nil
        CellDB["tools"]["dispelRequest"] = nil

        -- add menuPosition
        if not CellDB["general"]["menuPosition"] then
            CellDB["general"]["menuPosition"] = "top_bottom"
        end

        -- update health color
        if CellDB["appearance"]["barColor"][1] == "Class Color" then
            CellDB["appearance"]["barColor"][1] = "class_color"
        elseif CellDB["appearance"]["barColor"][1] == "Class Color (dark)" then
            CellDB["appearance"]["barColor"][1] = "class_color_dark"
        elseif CellDB["appearance"]["barColor"][1] == "Gradient" then
            CellDB["appearance"]["barColor"][1] = "gradient"
        elseif CellDB["appearance"]["barColor"][1] == "Custom Color" then
            CellDB["appearance"]["barColor"][1] = "custom"
        end

        -- update loss color
        if CellDB["appearance"]["lossColor"][1] == "Class Color" then
            CellDB["appearance"]["lossColor"][1] = "class_color"
        elseif CellDB["appearance"]["lossColor"][1] == "Class Color (dark)" then
            CellDB["appearance"]["lossColor"][1] = "class_color_dark"
        elseif CellDB["appearance"]["lossColor"][1] == "Gradient" then
            CellDB["appearance"]["lossColor"][1] = "gradient"
        elseif CellDB["appearance"]["lossColor"][1] == "Custom Color" then
            CellDB["appearance"]["lossColor"][1] = "custom"
        end

        -- update power color
        if CellDB["appearance"]["powerColor"][1] == "Power Color" then
            CellDB["appearance"]["powerColor"][1] = "power_color"
        elseif CellDB["appearance"]["powerColor"][1] == "Power Color (dark)" then
            CellDB["appearance"]["powerColor"][1] = "power_color_dark"
        elseif CellDB["appearance"]["powerColor"][1] == "Class Color" then
            CellDB["appearance"]["powerColor"][1] = "class_color"
        elseif CellDB["appearance"]["powerColor"][1] == "Custom Color" then
            CellDB["appearance"]["powerColor"][1] = "custom"
        end
    end

    -- r91-release
    if CellDB["revise"] and dbRevision < 91 then
        -- update spellRequest dataStructure
        if CellDB["glows"]["spellRequest"] and #CellDB["glows"]["spellRequest"] == 8 then
            local srIndices = {"enabled", "checkIfExists", "knownSpellsOnly", "freeCooldownOnly", "replyCooldown", "responseType", "timeout", "spells"}
            local spellIndices = {"spellId", "buffId", "keywords", "glowOptions", "isBuiltIn"}
            local newSR = {}
            for i, v in pairs(CellDB["glows"]["spellRequest"]) do
                if i == 8 then -- spells
                    newSR["spells"] = {}
                    for j, st in pairs(v) do
                        newSR["spells"][j] = {}
                        for k, sv in pairs(st) do
                            newSR["spells"][j][spellIndices[k]] = sv
                        end
                    end
                else
                    newSR[srIndices[i]] = v
                end
            end
            CellDB["glows"]["spellRequest"] = newSR
        end

        -- update dispelRequest dataStructure
        if CellDB["glows"]["dispelRequest"] and #CellDB["glows"]["dispelRequest"] == 6 then
            local drIndices = {"enabled", "dispellableByMe", "responseType", "timeout", "debuffs", "glowOptions"}
            local newDR = {}
            for i, v in pairs(CellDB["glows"]["dispelRequest"]) do
                newDR[drIndices[i]] = v
            end
            CellDB["glows"]["dispelRequest"] = newDR
        end
    end

    -- r93-release
    if CellDB["revise"] and dbRevision < 93 then
        -- add layout auto switch for Mythic
        for role, t in pairs(CellDB["layoutAutoSwitch"]) do
            if not t["mythic"] then
                t["mythic"] = "default"
            end
        end

        -- add allCooldowns
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][17] and layout["indicators"][17]["indicatorName"] ~= "allCooldowns" then
                tinsert(layout["indicators"], 17, {
                    ["name"] = "Externals + Defensives",
                    ["indicatorName"] = "allCooldowns",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"LEFT", "LEFT", -2, 5},
                    ["frameLevel"] = 10,
                    ["size"] = {12, 20},
                    ["showDuration"] = false,
                    ["num"] = 2,
                    ["orientation"] = "left-to-right",
                    ["font"] = {"Cell ".._G.DEFAULT, 11, "Outline", 2},
                })
            end
        end
    end

    -- r94-release
    if CellDB["revise"] and dbRevision < 94 then
        -- add auraIconOptions
        if not CellDB["appearance"]["auraIconOptions"] then
            CellDB["appearance"]["auraIconOptions"] = {
                ["animation"] = CellDB["appearance"]["iconAnimation"],
                ["durationColorEnabled"] = false,
                ["durationColors"] = {{0,1,0}, {1,1,0,0.5}, {1,0,0,3}},
                ["durationDecimal"] = 0,
            }

            CellDB["appearance"]["iconAnimation"] = nil
        end

        -- add y offset
        local modifications = {
            [15] = "externalCooldowns",
            [16] = "defensiveCooldowns",
            [17] = "allCooldowns",
            [20] = "debuffs",
            [21] = "raidDebuffs",
            [22] = "targetedSpells"
        }
        
        for _, layout in pairs(CellDB["layouts"]) do
            for i, t in pairs(layout["indicators"]) do
                if i <= Cell.defaults.builtIns then -- built-ins
                    if t["indicatorName"] == modifications[i] and not t["font"][5] then
                        t["font"][5] = 1
                    end
                elseif t["type"] == "icon" or t["type"] == "icons" then -- custom icon/icons
                    if not t["font"][5] then
                        t["font"][5] = 1
                    end
                end
            end
        end
    end

    -- r95-release
    if CellDB["revise"] and dbRevision < 95 then
        -- add round up
        if type(CellDB["appearance"]["auraIconOptions"]["durationRoundUp"]) ~= "boolean" then
            CellDB["appearance"]["auraIconOptions"]["durationRoundUp"] = false
        end

        -- change showDuration to duration for custom TEXT indicators
        for _, layout in pairs(CellDB["layouts"]) do
            for i, t in pairs(layout["indicators"]) do
                if t["type"] == "text" then
                    if type(t["duration"]) ~= "table" then
                        -- add new
                        t["duration"] = {
                            t["showDuration"], -- show duration
                            false, -- round up duration
                            0, -- decimal
                        }
                        -- remove old
                        t["showDuration"] = nil
                    end
                end
            end
        end
    end

    -- r96-release
    if CellDB["revise"] and dbRevision < 96 then
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][22] and layout["indicators"][22]["indicatorName"] == "targetedSpells" then
                if not F:TContains(layout["indicators"][22]["spells"], 332234) then -- 挥发精油
                    tinsert(layout["indicators"][22]["spells"], 332234)
                end
            end
        end
    end

    -- r97-release
    -- if CellDB["revise"] and dbRevision < 97 then
    --     if not CellDB["general"]["nickname"] then
    --         CellDB["general"]["nickname"] = {false}
    --     end
    -- end

    -- r98-release
    if CellDB["revise"] and dbRevision < 98 then
        -- add deathColor
        if not CellDB["appearance"]["deathColor"] then
            CellDB["appearance"]["deathColor"] = {false, {0.545, 0, 0}}
        end

        for _, layout in pairs(CellDB["layouts"]) do
            -- update frame level of aggro border
            if layout["indicators"][12] and layout["indicators"][12]["indicatorName"] == "aggroBorder" and layout["indicators"][12]["frameLevel"] == 1 then
                layout["indicators"][12]["frameLevel"] = 3
            end

            -- update roleTexture
            if layout["indicators"][5] and layout["indicators"][5]["indicatorName"] == "roleIcon" and not layout["indicators"][5]["roleTexture"] then
                layout["indicators"][5]["roleTexture"] = {}
                layout["indicators"][5]["roleTexture"][1] = layout["indicators"][5]["customTextures"][1] and "custom" or "default"
                layout["indicators"][5]["roleTexture"][2] = layout["indicators"][5]["customTextures"][2]
                layout["indicators"][5]["roleTexture"][3] = layout["indicators"][5]["customTextures"][3]
                layout["indicators"][5]["roleTexture"][4] = layout["indicators"][5]["customTextures"][4]

                layout["indicators"][5]["customTextures"] = nil
            end
        end
    end

    -- r99-release
    if CellDB["revise"] and dbRevision < 99 then
        -- remove old nickname
        CellDB["general"]["nickname"] = nil
        
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["indicators"][1] and layout["indicators"][1]["indicatorName"] == "nameText" then
                -- add Frame Level to Name Text indicator
                if not layout["indicators"][1]["frameLevel"] then
                    layout["indicators"][1]["frameLevel"] = 1
                end
                -- update color
                if layout["indicators"][1]["nameColor"][1] == "Class Color" then
                    layout["indicators"][1]["nameColor"][1] = "class_color"
                elseif layout["indicators"][1]["nameColor"][1] == "Custom Color" then
                    layout["indicators"][1]["nameColor"][1] = "custom"
                end
            end
        end
    end

    -- r103-release
    if CellDB["revise"] and dbRevision < 103 then
        if type(CellDB["appearance"]["accentColor"]) ~= "table" then
            CellDB["appearance"]["accentColor"] = {"class_color", {1, 0.26667, 0.4}}
        end
    end

    -- r107-release
    if CellDB["revise"] and dbRevision < 107 then
        -- add season 4 debuffs
        if not F:TContains(CellDB["bigDebuffs"], 373391) then
            tinsert(CellDB["bigDebuffs"], 373391) -- 梦魇
        end
        if not F:TContains(CellDB["bigDebuffs"], 373429) then
            tinsert(CellDB["bigDebuffs"], 373429) -- 腐臭虫群
        end
        Cell.vars.bigDebuffs = F:ConvertTable(CellDB["bigDebuffs"])
    end

    -- r117-release
    if CellDB["revise"] and dbRevision < 117 then
        -- enable shield in WotLK
        if Cell.isWrath then
            CellDB["appearance"]["shield"] = true
            CellDB["appearance"]["overshield"] = true
        end
    end

    -- r118-release
    if CellDB["revise"] and dbRevision < 118 then
        -- fix default value in Wrath Classic
        if Cell.isWrath and CellDB["tools"]["marks"][2] == "both_h" then
            CellDB["tools"]["marks"][2] = "target_h"
        end

        -- add size
        if not CellDB["tools"]["buffTracker"][3] then
            if Cell.isRetail then
                CellDB["tools"]["buffTracker"][3] = 32
            else
                CellDB["tools"]["buffTracker"][3] = 27
            end
        end
    end

    -- r119-release
    if CellDB["revise"] and dbRevision < 119 then
        -- spotlight
        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["spotlight"] then
                layout["spotlight"] = {false, {}, {}} -- enabled, units, position
            end
        end
    end

    -- r128-release
    if CellDB["revise"] and dbRevision < 128 then
        -- spotlight
        for _, layout in pairs(CellDB["layouts"]) do
            if layout["spotlight"] and #layout["spotlight"] ~= 5 then
                -- sizeEnabled
                layout["spotlight"][4] = false
                -- size
                layout["spotlight"][5] = {66, 46}
            end
        end
    end

    -- r129-release
    if CellDB["revise"] and dbRevision < 129 then
        if type(CellDB["general"]["hideBlizzard"]) == "boolean" then
            CellDB["general"]["hideBlizzardParty"] = CellDB["general"]["hideBlizzard"]
            CellDB["general"]["hideBlizzardRaid"] = CellDB["general"]["hideBlizzard"]
            CellDB["general"]["hideBlizzard"] = nil
        end

        if type(CellDB["appearance"]["useLibHealComm"]) ~= "boolean" then
            CellDB["appearance"]["useLibHealComm"] = false
        end
    end

    -- r132-release (merge r114 r115 r117)
    if CellDB["revise"] and dbRevision < 132 then
        local healthThresholdsIndex = Cell.defaults.indicatorIndices.healthThresholds
        local shieldBarIndex = Cell.defaults.indicatorIndices.shieldBar
        local dispelsIndex = Cell.defaults.indicatorIndices.dispels
        local consumablesIndex = Cell.defaults.indicatorIndices.consumables

        for _, layout in pairs(CellDB["layouts"]) do
            -- add healthThresholds
            if layout["indicators"][healthThresholdsIndex]["indicatorName"] ~= "healthThresholds" then
                tinsert(layout["indicators"], healthThresholdsIndex, {
                    ["name"] = "Health Thresholds",
                    ["indicatorName"] = "healthThresholds",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["thickness"] = 1,
                    ["thresholds"] = {
                        {0.35, {1, 0, 0, 1}},
                    },
                })
            end

            -- add ShieldBar back (r117)
            if layout["indicators"][shieldBarIndex]["indicatorName"] ~= "shieldBar" then
                tinsert(layout["indicators"], shieldBarIndex, {
                    ["name"] = "Shield Bar",
                    ["indicatorName"] = "shieldBar",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["position"] = {"BOTTOMLEFT", "BOTTOMLEFT", 0, 0},
                    ["frameLevel"] = 2,
                    ["height"] = 4,
                    ["color"] = {1, 1, 0, 1},
                })
            end
            
            -- add Consumables (r114)
            if not layout["indicators"][consumablesIndex] or layout["indicators"][consumablesIndex]["indicatorName"] ~= "consumables" then
                tinsert(layout["indicators"], consumablesIndex, {
                    ["name"] = "Consumables",
                    ["indicatorName"] = "consumables",
                    ["type"] = "built-in",
                    ["enabled"] = true,
                    ["speed"] = 1,
                })
            end
            
            -- add speed to Consumables (r115)
            if not layout["indicators"][consumablesIndex]["speed"] then
                layout["indicators"][consumablesIndex]["speed"] = 1
            end
            
            -- add highlightType to Dispels (r115)
            if not layout["indicators"][dispelsIndex]["highlightType"] then
                layout["indicators"][dispelsIndex]["highlightType"] = "gradient"
            end
            
            -- add showDispelTypeIcons to Dispels (r115)
            if type(layout["indicators"][dispelsIndex]["showDispelTypeIcons"]) ~= "boolean" then
                layout["indicators"][dispelsIndex]["showDispelTypeIcons"] = true
            end
        end
    end

    -- r134-release add SILLY raid pets
    if CellDB["revise"] and dbRevision < 134 then
        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["pet"] then
                layout["pet"] = {CellDB["general"]["showPartyPets"], false, {}, layout["petSize"][1], {layout["petSize"][2], layout["petSize"][3]}} -- partyPetsEnabled, raidPetsEnabled, raidPetsPosition, sizeEnabled, size
                layout["petSize"] = nil
            end
        end
        CellDB["general"]["showPartyPets"] = nil
    end

    -- r137-release
    if CellDB["revise"] and dbRevision < 137 then
        if not strfind(CellDB["snippets"][0]["code"], "^%-%- snippets can be found") then
            CellDB["snippets"][0]["code"] = "-- snippets can be found at https://github.com/enderneko/Cell/tree/master/.snippets\n"..CellDB["snippets"][0]["code"]
        end
    end
   
    -- r138-release
    if CellDB["revise"] and dbRevision < 138 then
        if Cell.isRetail then
            -- 邪甲术
            if not F:TContains(CellDB["debuffBlacklist"], 387847) then
                tinsert(CellDB["debuffBlacklist"], 387847)
                Cell.vars.debuffBlacklist = F:ConvertTable(CellDB["debuffBlacklist"])
            end
        end

        for _, layout in pairs(CellDB["layouts"]) do
            if layout["spacing"] then
                layout["spacingX"] = layout["spacing"]
                layout["spacingY"] = layout["spacing"]
                layout["spacing"] = nil
            end
            if not layout["powerFilters"]["EVOKER"] then
                layout["powerFilters"]["EVOKER"] = {["DAMAGER"] = true, ["HEALER"] = true}
            end
        end
    end

    -- r139-release
    if CellDB["revise"] and dbRevision < 139 then
        if Cell.isRetail then
            -- 筋疲力尽
            if not F:TContains(CellDB["debuffBlacklist"], 390435) then
                tinsert(CellDB["debuffBlacklist"], 390435)
                Cell.vars.debuffBlacklist = F:ConvertTable(CellDB["debuffBlacklist"])
            end
        end
    end

    -- r146-release
    if CellDB["revise"] and dbRevision < 146 then
        if Cell.isRetail then
            -- add "Initials"
            for class, t in pairs(CellDB["clickCastings"]) do
                -- fix alwaysTargeting
                if not t["alwaysTargeting"] then
                    t["alwaysTargeting"] = {["common"] = "disabled"}
                end
                -- set up initial spec
                local specID = GetSpecializationInfoForClassID(F:GetClassID(class), 5)
                t["alwaysTargeting"][specID] = "disabled"
                t[specID] = {
                    {"type1", "target"},
                    {"type2", "togglemenu"},
                }
            end
        end
    end

    -- r147-release
    if CellDB["revise"] and dbRevision < 147 then
        if Cell.isRetail then
            for role, t in pairs(CellDB["layoutAutoSwitch"]) do
                if t["raid"] then
                    t["raid_outdoor"] = t["raid"]
                    t["raid_instance"] = t["raid"]
                    t["raid"] = nil
                end
                if t["mythic"] then
                    t["raid_mythic"] = t["mythic"]
                    t["mythic"] = nil
                end
            end
        end

        -- appearance
        if type(CellDB["appearance"]["healPrediction"]) == "boolean" then
            CellDB["appearance"]["healPrediction"] = {CellDB["appearance"]["healPrediction"], false, {1, 1, 1, 0.4}}
        end
        if type(CellDB["appearance"]["shield"]) == "boolean" then
            CellDB["appearance"]["shield"] = {CellDB["appearance"]["shield"], {1, 1, 1, 0.4}}
        end
        if type(CellDB["appearance"]["healAbsorb"]) == "boolean" then
            CellDB["appearance"]["healAbsorb"] = {CellDB["appearance"]["healAbsorb"], {1, 0.1, 0.1, 0.9}}
        end

        -- custom indicator
        for _, layout in pairs(CellDB["layouts"]) do
            for _, indicator in pairs(layout["indicators"]) do
                if indicator["type"] == "bar" then
                    if not indicator["orientation"] then indicator["orientation"] = "horizontal" end
                    if type(indicator["showStack"]) ~= "boolean" then
                        indicator["showStack"] = false
                        indicator["font"] = {"Cell ".._G.DEFAULT, 11, "Outline", 0, 0}
                    end
                elseif indicator["type"] == "rect" then
                    if type(indicator["showStack"]) ~= "boolean" then
                        indicator["showStack"] = false
                        indicator["font"] = {"Cell ".._G.DEFAULT, 11, "Outline", 0, 0}
                    end
                end
            end
        end
    end

    -- r148-release
    if CellDB["revise"] and charaDbRevision and charaDbRevision < 148 then
        for role, t in pairs(CellCharacterDB["layoutAutoSwitch"]) do
            if not t["raid_outdoor"] then
                t["raid_outdoor"] = t["raid25"]
            end
        end
    end

    -- r149-release
    if CellDB["revise"] and dbRevision < 149 then
        -- friendlyNPC -> npc
        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["npc"] then
                -- rename
                layout["npc"] = layout["friendlyNPC"]
                layout["friendlyNPC"] = nil
                -- add sizeEnabled and size
                layout["npc"][4] = false
                layout["npc"][5] = {66, 46}
            end
        end
    end

    -- r150-release
    if CellDB["revise"] and dbRevision < 150 then
        local healthThresholds = Cell.defaults.indicatorIndices["healthThresholds"]
        local dispels = Cell.defaults.indicatorIndices["dispels"]
        local mitigation = Cell.defaults.indicatorIndices["tankActiveMitigation"]
        local aggroBar = Cell.defaults.indicatorIndices["aggroBar"]

        for _, layout in pairs(CellDB["layouts"]) do
            --! check healthThresholds AGAIN
            if layout["indicators"][healthThresholds]["indicatorName"] ~= "healthThresholds" then
                tinsert(layout["indicators"], healthThresholds, {
                    ["name"] = "Health Thresholds",
                    ["indicatorName"] = "healthThresholds",
                    ["type"] = "built-in",
                    ["enabled"] = false,
                    ["thickness"] = 1,
                    ["thresholds"] = {
                        {0.35, {1, 0, 0, 1}},
                    },
                })
            end
            -- add orientation to Dispels
            if layout["indicators"][dispels] and not layout["indicators"][dispels]["orientation"] then
                layout["indicators"][dispels]["orientation"] = "right-to-left"
            end
            -- update bars
            if Cell.isRetail and mitigation and layout["indicators"][mitigation] then
                layout["indicators"][mitigation]["size"][1] = layout["indicators"][mitigation]["size"][1] + 2
                layout["indicators"][mitigation]["size"][2] = layout["indicators"][mitigation]["size"][2] + 2
                if layout["indicators"][mitigation]["position"][3] == 10 and layout["indicators"][mitigation]["position"][4] == -1 then
                    layout["indicators"][mitigation]["position"][3] = 9
                    layout["indicators"][mitigation]["position"][4] = 0
                end
            end
            if layout["indicators"][aggroBar] then
                layout["indicators"][aggroBar]["size"][1] = layout["indicators"][aggroBar]["size"][1] + 2
                layout["indicators"][aggroBar]["size"][2] = layout["indicators"][aggroBar]["size"][2] + 2
                if layout["indicators"][aggroBar]["position"][3] == 1 and layout["indicators"][aggroBar]["position"][4] == 0 then
                    layout["indicators"][aggroBar]["position"][3] = 0
                    layout["indicators"][aggroBar]["position"][4] = -1
                end
            end
        end

        if Cell.isRetail then
            -- targetedSpells
            -- 红玉新生法池
            if not F:TContains(CellDB["targetedSpellsList"], 372858) then -- 灼热打击
                tinsert(CellDB["targetedSpellsList"], 372858)
            end
            -- 奈萨鲁斯
            if not F:TContains(CellDB["targetedSpellsList"], 374533) then -- 炽热挥舞
                tinsert(CellDB["targetedSpellsList"], 374533)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 377018) then -- 熔火真金
                tinsert(CellDB["targetedSpellsList"], 377018)
            end
            -- 蕨皮山谷
            if not F:TContains(CellDB["targetedSpellsList"], 381444) then -- 野蛮冲撞
                tinsert(CellDB["targetedSpellsList"], 381444)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 373912) then -- 腐朽打击
                tinsert(CellDB["targetedSpellsList"], 373912)
            end
            -- 英灵殿
            if not F:TContains(CellDB["targetedSpellsList"], 193092) then -- 放血扫击
                tinsert(CellDB["targetedSpellsList"], 193092)
            end

            -- debuffBlacklist
            if not F:TContains(CellDB["debuffBlacklist"], 213213) then -- 伪装
                tinsert(CellDB["debuffBlacklist"], 213213)
            end

            -- bigDebuffs
            if not F:TContains(CellDB["bigDebuffs"], 240559) then -- 重伤
                tinsert(CellDB["bigDebuffs"], 240559)
            end
            if not F:TContains(CellDB["bigDebuffs"], 396369) then -- 闪电标记
                tinsert(CellDB["bigDebuffs"], 396369)
            end
            if not F:TContains(CellDB["bigDebuffs"], 396364) then -- 狂风标记
                tinsert(CellDB["bigDebuffs"], 396364)
            end
        end
    end

    -- r152-release
    if CellDB["revise"] and dbRevision < 152 then
        if Cell.isRetail then
            local found1, found2
            for _, t in pairs(CellDB["consumables"]) do
                if t[1] == 370511 then found1 = true end
                if t[1] == 371024 then found2 = true end
            end
            if not found1 then
                tinsert(CellDB["consumables"], {
                    370511, -- 振奋治疗药水
                    {"A", {1, 0.1, 0.1}},
                })
            end
            if not found2 then
                tinsert(CellDB["consumables"], {
                    371024, -- 元素强能药水
                    {"C3", {1, 1, 0}},
                })
            end
            Cell.vars.consumables = I:ConvertConsumables(CellDB["consumables"])

            -- 英灵殿
            if not F:TContains(CellDB["targetedSpellsList"], 193659) then -- 邪炽冲刺
                tinsert(CellDB["targetedSpellsList"], 193659)
            end
        end

        for _, layout in pairs(CellDB["layouts"]) do
            local nameText = Cell.defaults.indicatorIndices.healthText
            if layout["indicators"][nameText] and layout["indicators"][nameText]["indicatorName"] == "nameText" then
                if type(layout["indicators"][nameText]["hideFull"]) == "boolean" then
                    layout["indicators"][nameText]["hideIfEmptyOrFull"] = layout["indicators"][nameText]["hideFull"]
                    layout["indicators"][nameText]["hideFull"] = nil
                end
            end
        end
    end

    -- r153-release
    if CellDB["revise"] and dbRevision < 153 then
        if Cell.isRetail then
            -- targetedSpells
            -- 青龙寺
            if not F:TContains(CellDB["targetedSpellsList"], 106823) then -- 翔龙猛袭
                tinsert(CellDB["targetedSpellsList"], 106823)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 106841) then -- 青龙猛袭
                tinsert(CellDB["targetedSpellsList"], 106841)
            end
            -- 群星庭院
            if not F:TContains(CellDB["targetedSpellsList"], 211473) then -- 暗影鞭笞
                tinsert(CellDB["targetedSpellsList"], 211473)
            end
            -- 英灵殿
            if not F:TContains(CellDB["targetedSpellsList"], 192018) then -- 光明之盾
                tinsert(CellDB["targetedSpellsList"], 192018)
            end
            -- 化身巨龙牢窟
            if not F:TContains(CellDB["targetedSpellsList"], 375870) then -- 致死石爪
                tinsert(CellDB["targetedSpellsList"], 375870)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 395906) then -- 电化之颌
                tinsert(CellDB["targetedSpellsList"], 395906)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 372158) then -- 破甲一击
                tinsert(CellDB["targetedSpellsList"], 372158)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 372056) then -- 碾压
                tinsert(CellDB["targetedSpellsList"], 372056)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 375580) then -- 西风猛击
                tinsert(CellDB["targetedSpellsList"], 375580)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 376276) then -- 震荡猛击
                tinsert(CellDB["targetedSpellsList"], 376276)
            end
            -- 红玉新生法池
            if not F:TContains(CellDB["targetedSpellsList"], 381512) then -- 风暴猛击
                tinsert(CellDB["targetedSpellsList"], 381512)
            end
            -- 碧蓝魔馆
            if not F:TContains(CellDB["targetedSpellsList"], 374789) then -- 注能打击
                tinsert(CellDB["targetedSpellsList"], 374789)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 372222) then -- 奥术顺劈
                tinsert(CellDB["targetedSpellsList"], 372222)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 384978) then -- 巨龙打击
                tinsert(CellDB["targetedSpellsList"], 384978)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 391136) then -- 肩部猛击
                tinsert(CellDB["targetedSpellsList"], 391136)
            end
            -- 诺库德阻击战
            if not F:TContains(CellDB["targetedSpellsList"], 376827) then -- 传导打击
                tinsert(CellDB["targetedSpellsList"], 376827)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 376829) then -- 雷霆打击
                tinsert(CellDB["targetedSpellsList"], 376829)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 375937) then -- 撕裂猛击
                tinsert(CellDB["targetedSpellsList"], 375937)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 375929) then -- 野蛮打击
                tinsert(CellDB["targetedSpellsList"], 375929)
            end

            Cell.vars.targetedSpellsList = F:ConvertTable(CellDB["targetedSpellsList"])
        end
    end

    -- r154-release
    if CellDB["revise"] and dbRevision < 154 then
        if Cell.isRetail then
            -- 诺库德阻击战
            if not F:TContains(CellDB["targetedSpellsList"], 376644) then -- 钢铁之矛
                tinsert(CellDB["targetedSpellsList"], 376644)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 376865) then -- 静电之矛
                tinsert(CellDB["targetedSpellsList"], 376865)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 382836) then -- 残杀
                tinsert(CellDB["targetedSpellsList"], 382836)
            end
            -- 英灵殿
            if not F:TContains(CellDB["targetedSpellsList"], 196838) then -- 血之气息
                tinsert(CellDB["targetedSpellsList"], 196838)
            end
        end
    end

    -- r156-release
    if CellDB["revise"] and dbRevision < 156 then
        if CellDB["customDefensives"] then
            CellDB["defensives"]["custom"] = CellDB["customDefensives"]
            CellDB["customDefensives"] = nil
        end
        if CellDB["customExternals"] then
            CellDB["externals"]["custom"] = CellDB["customExternals"]
            CellDB["customExternals"] = nil
        end
    end

    -- r158-release
    if CellDB["revise"] and dbRevision < 158 then
        --! Missing Buffs indicator only works on Retail
        --! because it's difficult to check Blessings on Wrath
        if Cell.isRetail then
            local index = Cell.defaults.indicatorIndices.missingBuffs
            for _, layout in pairs(CellDB["layouts"]) do
                if not layout["indicators"][index] or layout["indicators"][index]["indicatorName"] ~= "missingBuffs" then
                    tinsert(layout.indicators, index, {
                        ["name"] = "Missing Buffs",
                        ["indicatorName"] = "missingBuffs",
                        ["type"] = "built-in",
                        ["enabled"] = false,
                        -- ["trackByName"] = Cell.isWrath,
                        ["position"] = {"BOTTOMRIGHT", "BOTTOMRIGHT", 0, 4},
                        ["frameLevel"] = 10,
                        ["size"] = {13, 13},
                        ["num"] = 3,
                        ["orientation"] = "right-to-left",
                    })
                end
            end
        end
    end

    -- r162-release
    if CellDB["revise"] and dbRevision < 162 then
        if type(CellDB["general"]["sortPartyByRole"]) == "boolean" then
            for _, layout in pairs(CellDB["layouts"]) do
                layout["sortByRole"] = CellDB["general"]["sortPartyByRole"]
            end
            CellDB["general"]["sortPartyByRole"] = nil
        end
    end

    -- r163-release
    if CellDB["revise"] and dbRevision < 163 then
        if type(CellDB["appearance"]["strata"]) ~= "string" then
            CellDB["appearance"]["strata"] = "MEDIUM"
        end
    end
    
    -- r164-release
    if CellDB["revise"] and dbRevision < 164 then
        for class, t in pairs(CellDB["clickCastings"]) do
            if type(t["smartResurrection"]) ~= "string" then
                t["smartResurrection"] = "disabled"
            end
        end
    end

    -- r168-release
    if CellDB["revise"] and dbRevision < 168 then
        if Cell.isRetail then
            -- targetedSpells
            -- 亚贝鲁斯，焰影熔炉
            if not F:TContains(CellDB["targetedSpellsList"], 401022) then -- 灾祸掠击
                tinsert(CellDB["targetedSpellsList"], 401022)
            end
            if not F:TContains(CellDB["targetedSpellsList"], 407790) then -- 身影碎离
                tinsert(CellDB["targetedSpellsList"], 407790)
            end
        end
    end

    -- r169-release
    if CellDB["revise"] and dbRevision < 169 then
        if Cell.isRetail then
            local privateAuras = Cell.defaults.indicatorIndices["privateAuras"]
    
            for _, layout in pairs(CellDB["layouts"]) do
                if layout["indicators"][privateAuras]["indicatorName"] ~= "privateAuras" then
                    tinsert(layout["indicators"], privateAuras, {
                        ["name"] = "Private Auras",
                        ["indicatorName"] = "privateAuras",
                        ["type"] = "built-in",
                        ["enabled"] = true,
                        ["position"] = {"TOP", "TOP", 0, 3},
                        ["frameLevel"] = 25,
                        ["size"] = {18, 18},
                        ["privateAuraOptions"] = {true, false},
                    })
                end
            end
        end
    end

    -- r170-release
    if CellDB["revise"] and dbRevision < 170 then
        if not strfind(CellDB["snippets"][0]["code"], "CELL_NICKTAG_ENABLED") then
            CellDB["snippets"][0]["code"] = CellDB["snippets"][0]["code"].."\n\n-- Use nicknames from Details! Damage Meter (boolean, NickTag-1.0 library)\nCELL_NICKTAG_ENABLED = false"
        end

        if Cell.isWrath then
            local index = Cell.defaults.indicatorIndices.missingBuffs
            for _, layout in pairs(CellDB["layouts"]) do
                if not layout["indicators"][index] or layout["indicators"][index]["indicatorName"] ~= "missingBuffs" then
                    tinsert(layout.indicators, index, {
                        ["name"] = "Missing Buffs",
                        ["indicatorName"] = "missingBuffs",
                        ["type"] = "built-in",
                        ["enabled"] = false,
                        ["buffByMe"] = false,
                        ["position"] = {"BOTTOMRIGHT", "BOTTOMRIGHT", 0, 4},
                        ["frameLevel"] = 10,
                        ["size"] = {13, 13},
                        ["num"] = 3,
                        ["orientation"] = "right-to-left",
                    })
                end
            end
        end
    end

    -- r171-release
    if CellDB["revise"] and dbRevision < 171 then
        if not strfind(CellDB["snippets"][0]["code"], "CELL_DISPEL_EVOKER_CAUTERIZING_FLAME") then
            CellDB["snippets"][0]["code"] = CellDB["snippets"][0]["code"].."\n\n-- Add Evoker spell Cauterizing Flame into dispel checker (boolean)\nCELL_DISPEL_EVOKER_CAUTERIZING_FLAME = false"
        end
    end

    -- r173-release
    if CellDB["revise"] and dbRevision < 173 then
        local leaderIcon = Cell.defaults.indicatorIndices["leaderIcon"]

        for _, layout in pairs(CellDB["layouts"]) do
            if type(layout["indicators"][leaderIcon]["hideInCombat"]) ~= "boolean" then
                layout["indicators"][leaderIcon]["hideInCombat"] = true
            end
        end
    end
    
    -- r174-release
    if CellDB["revise"] and dbRevision < 174 then
        for _, layout in pairs(CellDB["layouts"]) do
            for _, indicator in pairs(layout["indicators"]) do
                local name = indicator["indicatorName"]
                local type = indicator["type"]
                local font = indicator["font"]

                if font and #font == 5 then
                    if name == "debuffs" or name == "raidDebuffs" or name == "externalCooldowns" or name == "defensiveCooldowns" or name == "allCooldowns" or type == "icon" or type == "icons" then
                        indicator["font"] = {
                            {font[1], font[2], font[3], "TOPRIGHT", font[4], font[5], {1, 1, 1}}, -- stackFont
                            {font[1], font[2], font[3], "BOTTOMRIGHT", font[4], -font[5], {1, 1, 1}}, -- durationFont
                        }

                    elseif name == "targetedSpells" then
                        indicator["font"] = {font[1], font[2], font[3], "TOPRIGHT", font[4], font[5], {1, 1, 1}}

                    elseif type == "bar" or type == "rect" then
                        indicator["font"] = {font[1], font[2], font[3], "CENTER", font[4], font[5], {1, 1, 1}}
                    end
                end
            end
        end
    end

    -- r176-release
    if CellDB["revise"] and dbRevision < 176 then
        -- full hp color
        if type(CellDB["appearance"]["fullColor"]) ~= "table" then
            CellDB["appearance"]["fullColor"] = {false, {0.2, 0.2, 0.2}}
        end
    end

    -- r177-release
    if CellDB["revise"] and dbRevision < 177 then
        if Cell.isRetail then
            --! evoker Augmentation 1473
            if CellDB["clickCastings"]["EVOKER"] then
                if not CellDB["clickCastings"]["EVOKER"][1473] then
                    CellDB["clickCastings"]["EVOKER"]["alwaysTargeting"][1473] = "disabled"
                    CellDB["clickCastings"]["EVOKER"][1473] = {
                        {"type1", "target"},
                        {"type2", "togglemenu"},
                        {"type-shiftR", "spell", 361227},
                    }
                end
            end
        end
    end

    -- r178-release
    if CellDB["revise"] and dbRevision < 178 then
        if Cell.isWrath then
            for _, layout in pairs(CellDB["layouts"]) do
                local index = Cell.defaults.indicatorIndices.powerWordShield
                if layout["indicators"][index]["indicatorName"] ~= "powerWordShield" then
                    tinsert(layout["indicators"], index, {
                        ["name"] = "PW:S",
                        ["indicatorName"] = "powerWordShield",
                        ["type"] = "built-in",
                        ["enabled"] = false,
                        ["position"] = {"CENTER", "BOTTOMRIGHT", -7, 7},
                        ["frameLevel"] = 10,
                        ["size"] = {20, 20},
                        ["shieldByMe"] = true,
                    })
                end
            end
        end
    end

    -- r181-release
    if CellDB["revise"] and dbRevision < 181 then
        if Cell.isWrath then
            for _, layout in pairs(CellDB["layouts"]) do
                local index = Cell.defaults.indicatorIndices.powerWordShield
                if type(layout["indicators"][index]["shape"]) ~= "string" then
                    layout["indicators"][index]["shape"] = "circle"
                end
            end
        end
    end

    -- r182-release
    if CellDB["revise"] and dbRevision < 182 then
        if Cell.isWrath then
            if CellDB["clickCastings"] and CellDB["clickCastings"][Cell.vars.playerClass] then
                if not CellCharacterDB["clickCastings"]["processed"] then
                    CellCharacterDB["clickCastings"] = CellDB["clickCastings"][Cell.vars.playerClass]
                    Cell.vars.clickCastings = CellCharacterDB["clickCastings"]
                    -- flag as processed
                    CellCharacterDB["clickCastings"]["processed"] = true
                end
            end
        end

        for _, layout in pairs(CellDB["layouts"]) do
            if not layout["main"] then
                layout["main"] = {
                    ["sortByRole"] = layout["sortByRole"],
                    ["hideSelf"] = layout["hideSelf"],
                    ["size"] = layout["size"],
                    ["position"] = layout["position"],
                    ["powerSize"] = layout["powerSize"],
                    ["orientation"] = layout["orientation"],
                    ["anchor"] = layout["anchor"],
                    ["spacingX"] = layout["spacingX"],
                    ["spacingY"] = layout["spacingY"],
                    ["columns"] = layout["columns"],
                    ["rows"] = layout["rows"],
                    ["groupSpacing"] = layout["groupSpacing"],
                }
                
                layout["pet"] = {
                    ["partyEnabled"] = layout["pet"][1],
                    ["raidEnabled"] = layout["pet"][2],
                    ["sameSizeAsMain"] = not layout["pet"][4],
                    ["sameArrangementAsMain"] = true,
                    ["size"] = layout["pet"][5],
                    ["position"] = layout["pet"][3],
                    ["powerSize"] = layout["powerSize"],
                    ["orientation"] = layout["orientation"],
                    ["anchor"] = layout["anchor"],
                    ["spacingX"] = layout["spacingX"],
                    ["spacingY"] = layout["spacingY"],
                }

                layout["npc"] = {
                    ["enabled"] = layout["npc"][1],
                    ["separate"] = layout["npc"][2],
                    ["sameSizeAsMain"] = not layout["npc"][4],
                    ["sameArrangementAsMain"] = true,
                    ["size"] = layout["npc"][5],
                    ["position"] = layout["npc"][3],
                    ["powerSize"] = layout["powerSize"],
                    ["orientation"] = layout["orientation"],
                    ["anchor"] = layout["anchor"],
                    ["spacingX"] = layout["spacingX"],
                    ["spacingY"] = layout["spacingY"],
                }

                layout["spotlight"] = {
                    ["enabled"] = layout["spotlight"][1],
                    ["units"] = layout["spotlight"][2],
                    ["sameSizeAsMain"] = not layout["spotlight"][4],
                    ["sameArrangementAsMain"] = true,
                    ["size"] = layout["spotlight"][5],
                    ["position"] = layout["spotlight"][3],
                    ["powerSize"] = layout["powerSize"],
                    ["orientation"] = layout["orientation"],
                    ["anchor"] = layout["anchor"],
                    ["spacingX"] = layout["spacingX"],
                    ["spacingY"] = layout["spacingY"],
                }
            end

            layout["size"] = nil
            layout["position"] = nil
            layout["powerSize"] = nil
            layout["spacingX"] = nil
            layout["spacingY"] = nil
            layout["orientation"] = nil
            layout["anchor"] = nil
            layout["columns"] = nil
            layout["rows"] = nil
            layout["groupSpacing"] = nil
            layout["sortByRole"] = nil
            layout["hideSelf"] = nil
        end
    end

    -- r186-release
    if CellDB["revise"] and dbRevision < 186 then
        if CellDB["glows"] then
            CellDB["spellRequest"] = CellDB["glows"]["spellRequest"]
            CellDB["dispelRequest"] = CellDB["glows"]["dispelRequest"]
            CellDB["glows"] = nil

            CellDB["spellRequest"]["sharedIconOptions"] = {
                "beat", -- [1] animation
                27, -- [2] size
                "BOTTOMRIGHT", -- [3] anchor
                "BOTTOMRIGHT", -- [4] anchorTo
                0, -- [5] x
                0, -- [6] y
            }
    
            for _, t in pairs(CellDB["spellRequest"]["spells"]) do
                t["type"] = "icon"
                t["icon"] = select(3, GetSpellInfo(t["spellId"]))
                t["iconColor"] = t["glowOptions"][2][1]
            end
            
            CellDB["dispelRequest"]["textOptions"] = {
                "A",
                {1, 0, 0, 1}, -- [1] color 
                32, -- [2] size
                "TOPLEFT", -- [3] anchor
                "TOPLEFT", -- [4] anchorTo
                -1, -- [5] x
                5, -- [6] y
            }
            
            CellDB["dispelRequest"]["type"] = "text"
        end

        if Cell.isWrath then
            CellCharacterDB["clickCastings"]["class"] = Cell.vars.playerClass
        end
    end

    -- r187-release
    if CellDB["revise"] and dbRevision < 187 then
        if type(CellDB["dispelRequest"]["textOptions"][1]) ~= "string" then
            tinsert(CellDB["dispelRequest"]["textOptions"][1], 1, "A")
        end

        if Cell.isRetail and type(CellDB["quickCast"]) == "table" then
            for class, classTbl in pairs(CellDB["quickCast"]) do
                for spec, specTbl in pairs(classTbl) do
                    if not specTbl["glowBuffsColor"] then
                        specTbl["glowBuffsColor"] = {1, 1, 0, 1}
                    end
                    if not specTbl["glowCasts"] then
                        specTbl["glowCasts"] = {}
                        specTbl["glowCastsColor"] = {1, 0, 1, 1}
                    end
                end
            end
        end
    end
    
    -- r188-release
    if CellDB["revise"] and dbRevision < 188 then
        if Cell.isRetail and type(CellDB["quickCast"]) == "table" then
            for class, classTbl in pairs(CellDB["quickCast"]) do
                for spec, specTbl in pairs(classTbl) do
                    if strfind(specTbl["orientation"], "^vertical") or strfind(specTbl["orientation"], "^horizontal") then
                        specTbl["orientation"] = specTbl["orientation"]:gsub("^vertical%-", "")
                        specTbl["orientation"] = specTbl["orientation"]:gsub("^horizontal%-", "")
                    end
                end
            end
        end
    end
    ]=]

    -- r190-beta
    if CellDB["revise"] and dbRevision < 190 then
        if not strfind(CellDB["snippets"][0]["code"], "CELL_TOOLTIP_REMOVE_RAID_SETUP_DETAILS") then
            CellDB["snippets"][0]["code"] = CellDB["snippets"][0]["code"].."\n\n-- remove raid setup details from the tooltip of the Raid button (boolean)\nCELL_TOOLTIP_REMOVE_RAID_SETUP_DETAILS = false"
        end

        if Cell.isRetail then
            for _, layout in pairs(CellDB["layouts"]) do
                local index = Cell.defaults.indicatorIndices.crowdControls
                if layout["indicators"][index]["indicatorName"] ~= "crowdControls" then
                    tinsert(layout["indicators"], index, {
                        ["name"] = "Crowd Controls",
                        ["indicatorName"] = "crowdControls",
                        ["type"] = "built-in",
                        ["enabled"] = false,
                        ["position"] = {"CENTER", "CENTER", 0, 0},
                        ["frameLevel"] = 20,
                        ["size"] = {22, 22},
                        ["border"] = 2,
                        ["num"] = 3,
                        ["font"] = {
                            {"Cell ".._G.DEFAULT, 11, "Outline", "TOPRIGHT", 2, 1, {1, 1, 1}},
                            {"Cell ".._G.DEFAULT, 11, "Outline", "BOTTOMRIGHT", 2, -1, {1, 1, 1}},
                        },
                        ["orientation"] = "left-to-right",
                    })
                end
            end
        end
    end

    -- r195-release
    if CellDB["revise"] and dbRevision < 195 then
        if not strfind(CellDB["snippets"][0]["code"], "CELL_BORDER_SIZE") then
            CellDB["snippets"][0]["code"] = CellDB["snippets"][0]["code"].."\n\n-- border thickness: unit button and icon (number)\nCELL_BORDER_SIZE = 1"
        end

        local filters
        
        if Cell.isRetail then
            filters = {
                ["PWF"] = true,
                ["MotW"] = true,
                ["AB"] = true,
                ["BS"] = true,
                ["BotB"] = true,
            }
        else
            filters = {
                ["PWF"] = true,
                ["DS"] = true,
                ["SP"] = true,
                ["AB"] = true,
                ["MotW"] = true,
                ["PALADIN"] = true,
                ["WARRIOR"] = true,
            }
        end

        for _, layout in pairs(CellDB["layouts"]) do
            local index = Cell.defaults.indicatorIndices.missingBuffs
            if type(layout["indicators"][index]["filters"]) ~= "table" then
                layout["indicators"][index]["filters"] = F:Copy(filters)
                layout["indicators"][index]["filters"]["buffByMe"] = layout["indicators"][index]["buffByMe"]
                layout["indicators"][index]["buffByMe"] = nil
            end
        end
    end

    -- r196-release
    if CellDB["revise"] and dbRevision < 196 then
        if not strfind(CellDB["snippets"][0]["code"], "CELL_BORDER_COLOR") then
            CellDB["snippets"][0]["code"] = CellDB["snippets"][0]["code"].."\n\n-- unit button border color ({r, g, b, a}, number: 0-1)\nCELL_BORDER_COLOR = {0, 0, 0, 1}"
        end
    end

    -- r197-release
    if CellDB["revise"] and dbRevision < 197 then
        if Cell.isRetail then
            for c, ct in pairs(CellDB["quickCast"]) do
                for s, st in pairs(ct) do
                    if type(st["spacing"]) == "number" then
                        st["spacingX"] = st["spacing"]
                        st["spacingY"] = st["spacing"]
                        st["spacing"] = nil
                        st["lines"] = 6
                    end
                end
            end
        end

        if type(CellDB["tools"]["marks"][2]) ~= "boolean" then
            tinsert(CellDB["tools"]["marks"], 2, false)
        end
    end

    -- r198-release
    -- if CellDB["revise"] and dbRevision < 198 then
    --     for _, layout in pairs(CellDB["layouts"]) do
    --         local index = Cell.defaults.indicatorIndices.targetCounter
    --         if type(layout["indicators"][index]["filters"]) ~= "table" then
    --             layout["indicators"][index]["filters"] = {
    --                 ["outdoor"] = false,
    --                 ["pve"] = false,
    --                 ["pvp"] = true,
    --             }
    --         end
    --     end
    -- end

    -- r199-release
    if CellDB["revise"] and dbRevision < 199 then
        if not strfind(CellDB["snippets"][0]["code"], "CELL_SHOW_RAID_PET_OWNER_NAME") then
            CellDB["snippets"][0]["code"] = CellDB["snippets"][0]["code"].."\n\n-- show raid pet owner name (\"VEHICLE\", \"NAME\", nil)\nCELL_SHOW_RAID_PET_OWNER_NAME = nil"
        end

        for _, layout in pairs(CellDB["layouts"]) do
            for i, t in ipairs(layout["indicators"]) do
                if type(t["castByMe"]) == "boolean" then
                    t["castBy"] = t["castByMe"] and "me" or "anyone"
                    t["castByMe"] = nil
                end
            end
        end
    end

    -- r200-release
    if CellDB["revise"] and dbRevision < 200 then
        if #CellDB["tools"]["buffTracker"] ~= 4 then
            -- move position from 2 to 4
            CellDB["tools"]["buffTracker"][4] = CellDB["tools"]["buffTracker"][2]
            -- add orientation
            CellDB["tools"]["buffTracker"][2] = "left-to-right"
        end
        if #CellDB["tools"]["readyAndPull"] ~= 4 then
            -- add style
            tinsert(CellDB["tools"]["readyAndPull"], 2, "text_button")
        end
    end

    -- r201-release
    if CellDB["revise"] and dbRevision < 201 then
        if Cell.isRetail then
            -- 阿梅达希尔，梦境之愿
            if not F:TContains(CellDB["targetedSpellsList"], 418637) then -- 狂怒冲锋
                tinsert(CellDB["targetedSpellsList"], 418637)
            end
        end
    end
   
    -- r202-release
    -- if CellDB["revise"] and dbRevision < 202 then
    --     -- custom indicator
    --     for _, layout in pairs(CellDB["layouts"]) do
    --         for _, indicator in pairs(layout["indicators"]) do
    --             if indicator["type"] == "icon" or indicator["type"] == "icons" then
    --                 if type(indicator["showStack"]) ~= "boolean" then
    --                     indicator["showStack"] = true
    --                 end
    --             end
    --         end
    --     end
    -- end

    -- r203-release
    if CellDB["revise"] and dbRevision < 203 then
        for _, layout in pairs(CellDB["layouts"]) do
            local index = Cell.defaults.indicatorIndices.targetCounter
            if type(layout["indicators"][index]["filters"]) ~= "table" then
                layout["indicators"][index]["filters"] = {
                    ["outdoor"] = false,
                    ["pve"] = false,
                    ["pvp"] = true,
                }
            end
        end
    end

    -- r205-release
    if CellDB["revise"] and dbRevision < 205 then
        for _, layout in pairs(CellDB["layouts"]) do
            local index = Cell.defaults.indicatorIndices.aggroBorder
            if layout["indicators"][index]["frameLevel"] == 3 then
                layout["indicators"][index]["frameLevel"] = 7
            end
        end

        if not CellDB["general"]["framePriority"] then
            CellDB["general"]["framePriority"] = "normal_spotlight"
        end
    end

    -- r206-release
    if CellDB["revise"] and dbRevision < 206 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- fix showStack for custom indicators
            for _, indicator in pairs(layout["indicators"]) do
                if indicator["type"] == "icon" or indicator["type"] == "icons" then
                    if type(indicator["showStack"]) ~= "boolean" then
                        indicator["showStack"] = true
                    end
                end
            end

            -- add showTimer for statusText
            local index = Cell.defaults.indicatorIndices.statusText
            if type(layout["indicators"][index]["showTimer"]) ~= "boolean" then
                layout["indicators"][index]["showTimer"] = true
            end
            -- add showBackground for statusText
            if type(layout["indicators"][index]["showBackground"]) ~= "boolean" then
                layout["indicators"][index]["showBackground"] = true
            end

            -- swap en/non-en length for name text
            index = Cell.defaults.indicatorIndices.nameText
            if layout["indicators"][index]["textWidth"][1] == "length" then
                if not layout["indicators"][index]["textWidth"][3] then -- en cilents
                    layout["indicators"][index]["textWidth"][3] = 3
                else -- aisan cilents
                    local temp = layout["indicators"][index]["textWidth"][2]
                    layout["indicators"][index]["textWidth"][2] = layout["indicators"][index]["textWidth"][3]
                    layout["indicators"][index]["textWidth"][3] = temp
                end
            end
        end

        if CellDB["general"]["framePriority"] == "normal_spotlight" then
            CellDB["general"]["framePriority"] = "normal_spotlight_quickassist"
        elseif CellDB["general"]["framePriority"] == "spotlight_normal" then
            CellDB["general"]["framePriority"] = "spotlight_normal_quickassist"
        end
    end

    -- r207-release
    if CellDB["revise"] and dbRevision < 207 then
        if Cell.isRetail then
            for spec, t in pairs(CellDB["quickAssist"]) do
                -- clickCastings -> buffs
                if not t["spells"]["mine"]["buffs"] then
                    t["spells"]["mine"]["buffs"] = t["spells"]["mine"]["clickCastings"]
                    t["spells"]["mine"]["clickCastings"] = nil
                    for _, st in pairs(t["spells"]["mine"]["buffs"]) do
                        if st[1] == -1 then st[1] = 0 end
                        tinsert(st, 2, "icon")
                    end
                end
                -- add bar options
                if not t["spells"]["mine"]["bar"] then
                    t["spells"]["mine"]["bar"] = {
                        ["position"] = {"TOPRIGHT", "BOTTOMRIGHT", 0, 1},
                        ["orientation"] = "top-to-bottom",
                        ["size"] = {75, 4},
                    }
                end
                -- add glow options
                if not t["spells"]["offensives"]["glow"] then
                    t["spells"]["offensives"]["glow"] = {
                        ["fadeOut"] = false,
                        ["options"] = {"None", {0.95,0.95,0.32,1}},
                    }
                end
                -- add filters
                if not t["layout"]["filters"] then
                    t["layout"]["filters"] = {
                        t["layout"]["filter"],
                        {"role", {["TANK"] = false, ["HEALER"] = false, ["DAMAGER"] = true}, false},
                        {"role", {["TANK"] = false, ["HEALER"] = false, ["DAMAGER"] = true}, false},
                        {"role", {["TANK"] = false, ["HEALER"] = false, ["DAMAGER"] = true}, false},
                        {"role", {["TANK"] = false, ["HEALER"] = false, ["DAMAGER"] = true}, false},
                        ["active"] = 1,
                    }
                    t["layout"]["filter"] = nil
                end
            end
        end
    end

    -- r209-release
    if CellDB["revise"] and dbRevision < 209 then
        -- add change-over-time to custom Color indicator
        for _, layout in pairs(CellDB["layouts"]) do
            for _, indicator in pairs(layout["indicators"]) do
                if indicator["type"] == "color" and #indicator["colors"] ~= 6 then
                    indicator["colors"][4] = {0,1,0} -- normal
                    indicator["colors"][5] = {1,1,0,0.5} -- percent
                    indicator["colors"][6] = {1,0,0,3} -- second
                end
            end
        end
    end

    -- r210-release
    if CellDB["revise"] and dbRevision < 210 then
        if not CellDB["debuffTypeColor"]["Bleed"] then
            CellDB["debuffTypeColor"]["Bleed"] = {r=1, g=0.2, b=0.6}
        end
    end
   
    -- r213-release
    if CellDB["revise"] and dbRevision < 213 then
        if Cell.isRetail then
            for spec, t in pairs(CellDB["quickAssist"]) do
                if not t["filters"] then
                    t["filters"] = t["layout"]["filters"]
                    t["filters"]["active"] = nil
                    t["filters"][6] = F:Copy(t["filters"][5])
                    t["filters"][7] = F:Copy(t["filters"][5])
                    t["layout"]["filters"] = nil
                end
                if not t["filterAutoSwitch"] then
                    t["filterAutoSwitch"] = {
                        ["party"] = 1,
                        ["raid"] = 1,
                        ["mythic"] = 1,
                        ["arena"] = 1,
                        ["battleground"] = 1,
                    }
                end
                for _, ft in pairs(t["filters"]) do
                    if ft[1] == "name" then
                        ft[3] = false
                    end
                end
            end
        end
    end

    -- r215-release
    if CellDB["revise"] and dbRevision < 215 then
        for _, layout in pairs(CellDB["layouts"]) do
            -- add role order option
            if not layout["main"]["roleOrder"] then
                layout["main"]["roleOrder"] = {"TANK", "HEALER", "DAMAGER"}
            end

            -- add color for tankActiveMitigation
            local index = Cell.defaults.indicatorIndices.tankActiveMitigation
            if index and type(layout["indicators"][index]["color"]) ~= "table" then
                layout["indicators"][index]["color"] = {"class_color", {0.25, 1, 0}}
            end

            -- rename nameColor to color
            index = Cell.defaults.indicatorIndices.nameText
            if type(layout["indicators"][index]["color"]) ~= "table" then
                layout["indicators"][index]["color"] = layout["indicators"][index]["nameColor"]
                if layout["indicators"][index]["color"][1] == "custom" then
                    layout["indicators"][index]["color"][1] = "custom_color"
                end
                layout["indicators"][index]["nameColor"] = nil
            end

            -- add showAnimation option
            for _, i in pairs(layout["indicators"]) do
                if i.indicatorName == "externalCooldowns" or i.indicatorName == "defensiveCooldowns" or i.indicatorName == "allCooldowns" or i.indicatorName == "debuffs"
                    or i.type == "icon" or i.type == "icons" then
                    if type(i.showAnimation) ~= "boolean" then
                        i.showAnimation = true
                    end
                end
            end
        end

        -- set alwaysUpdateDebuffs default to true
        if not CellDB["general"]["alwaysUpdateDebuffs"] then
            CellDB["general"]["alwaysUpdateDebuffs"] = true
        end
    end

    -- ----------------------------------------------------------------------- --
    --            update from old versions, validate all indicators            --
    -- ----------------------------------------------------------------------- --
    if CellDB["revise"] and CellDB["revise"] ~=  Cell.version then
        for layoutName, layout in pairs(CellDB["layouts"]) do
            local toValidate = F:Copy(Cell.defaults.indicatorIndices)
            local temp = {}
            
            -- built-ins
            for i, t in ipairs(layout["indicators"]) do
                local name = t["indicatorName"]
                if t["type"] == "built-in" and toValidate[name] then
                    if i == toValidate[name] then
                        -- copy valid indicator
                        -- print(layoutName, "RIGHT", i, name)
                        tinsert(temp, t)
                    else
                        -- search for correct indicator
                        local found
                        for j = i, #layout["indicators"] do
                            if name == layout["indicators"][j]["indicatorName"] then
                                -- print(layoutName, "WRONG_FOUND", j, "->", toValidate[name], name)
                                found = true
                                tinsert(temp, layout["indicators"][j])
                                break
                            end
                        end
                        -- not found, copy from Defaults
                        if not found then
                            -- print(layoutName, "WRONG_NOT_FOUND", i, name)
                            tinsert(temp, Cell.defaults.layout.indicators[toValidate[name]])
                        end
                    end
                    -- remove validated
                    toValidate[name] = nil
                end
            end
            
            -- customs
            local index = 1
            for i, t in ipairs(layout["indicators"]) do
                if t["type"] ~= "built-in" then
                    t["indicatorName"] = "indicator"..index
                    tinsert(temp, t)
                    index = index + 1
                end
            end

            layout["indicators"] = temp
        end
    end

    CellDB["revise"] = Cell.version
    if Cell.isVanilla or Cell.isWrath then
        CellCharacterDB["revise"] = Cell.version
    end
end