Skip to content

Commit

Permalink
hotfix(oauth2) missing migration for postgres (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
subnetmarco authored Dec 21, 2016
1 parent a76e642 commit 37af81e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions kong/plugins/oauth2/migrations/postgres.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,42 @@ return {
DROP TABLE oauth2_tokens;
]]
},
{
name = "2016-04-14-283949_serialize_redirect_uri",
up = function(_, _, factory)
local schema = factory.oauth2_credentials.schema
schema.fields.redirect_uri.type = "string"
local json = require "cjson"
local apps, err = factory.oauth2_credentials.db:find_all('oauth2_credentials', nil, schema);
if err then
return err
end
for _, app in ipairs(apps) do
local redirect_uri = {};
redirect_uri[1] = app.redirect_uri
local redirect_uri_str = json.encode(redirect_uri)
local req = "UPDATE oauth2_credentials SET redirect_uri='"..redirect_uri_str.."' WHERE id='"..app.id.."'"
local _, err = factory.oauth2_credentials.db:queries(req)
if err then
return err
end
end
end,
down = function(_,_,factory)
local apps, err = factory.oauth2_credentials:find_all()
if err then
return err
end
for _, app in ipairs(apps) do
local redirect_uri = app.redirect_uri[1]
local req = "UPDATE oauth2_credentials SET redirect_uri='"..redirect_uri.."' WHERE id='"..app.id.."'"
local _, err = factory.oauth2_credentials.db:queries(req)
if err then
return err
end
end
end
},
{
name = "2016-07-15-oauth2_code_credential_id",
up = [[
Expand Down

0 comments on commit 37af81e

Please sign in to comment.