Skip to content

Commit

Permalink
fix(jwt) preflight, add migration and remove workaround
Browse files Browse the repository at this point in the history
This belongs to PR #2744 which went into a minor version.
  • Loading branch information
Tieske committed Aug 2, 2017
1 parent 8de192e commit df7cab1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
26 changes: 25 additions & 1 deletion kong/plugins/jwt/migrations/cassandra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,29 @@ return {
ALTER TABLE jwt_secrets DROP algorithm;
ALTER TABLE jwt_secrets DROP rsa_public_key;
]]
}
},
{
name = "2017-07-31-113200_jwt_preflight_default",
up = function(_, _, dao)
for rows, err in dao.db.cluster:iterate([[
SELECT * FROM plugins WHERE name = 'jwt';
]]) do
if err then
return err
end

for _, row in ipairs(rows) do
if row.config.run_on_preflight == nil then
local _, err = dao.apis:update({
run_on_preflight = true,
}, { id = row.id })
if err then
return err
end
end
end
end
end,
down = function(_, _, dao) end -- not implemented
},
}
25 changes: 24 additions & 1 deletion kong/plugins/jwt/migrations/postgres.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,28 @@ return {
ALTER TABLE jwt_secrets DROP COLUMN algorithm;
ALTER TABLE jwt_secrets DROP COLUMN rsa_public_key;
]]
}
},
{
name = "2017-07-31-113200_jwt_preflight_default",
up = function(_, _, dao)
local rows, err = dao.db:query([[
SELECT * FROM plugins WHERE name = 'jwt';
]])
if err then
return err
end

for _, row in ipairs(rows) do
if row.config.run_on_preflight == nil then
local _, err = dao.apis:update({
run_on_preflight = true,
}, { id = row.id })
if err then
return err
end
end
end
end,
down = function(_, _, dao) end -- not implemented
},
}

0 comments on commit df7cab1

Please sign in to comment.