Skip to content

Commit

Permalink
fix(db) blue/green migration for route regex path (#9334)
Browse files Browse the repository at this point in the history
The steps of migration should happen in the up phase, not the teardown phase.

fix FT-3293
  • Loading branch information
StarlightIbuki authored Sep 2, 2022
1 parent 7879c9e commit 1d3bed9
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions kong/db/migrations/core/016_280_to_300.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ local function c_copy_vaults_beta_to_sm_vaults(coordinator)
end


local function c_normalize_regex_path(coordinator)
local function c_migrate_regex_path(coordinator)
for rows, err in coordinator:iterate("SELECT id, paths FROM routes") do
if err then
return nil, err
Expand Down Expand Up @@ -320,6 +320,8 @@ return {
$$;
]],

up_f = p_migrate_regex_path,

teardown = function(connector)
local _, err = connector:query([[
DROP TABLE IF EXISTS vaults_beta;
Expand All @@ -335,11 +337,6 @@ return {
return nil, err
end

_, err = p_migrate_regex_path(connector)
if err then
return nil, err
end

return true
end
},
Expand Down Expand Up @@ -406,6 +403,11 @@ return {
if err then
return nil, err
end

_, err = c_migrate_regex_path(coordinator)
if err then
return nil, err
end
end,

teardown = function(connector)
Expand Down Expand Up @@ -437,11 +439,6 @@ return {
return nil, err
end

_, err = c_normalize_regex_path(coordinator)
if err then
return nil, err
end

return true
end
},
Expand Down

0 comments on commit 1d3bed9

Please sign in to comment.