Skip to content

Commit

Permalink
add new migration to rockspec
Browse files Browse the repository at this point in the history
  • Loading branch information
liverpool8056 committed Mar 7, 2023
1 parent 61a8b50 commit ab74ca3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 11 deletions.
1 change: 1 addition & 0 deletions kong-3.2.1-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ build = {
["kong.db.migrations.core.016_280_to_300"] = "kong/db/migrations/core/016_280_to_300.lua",
["kong.db.migrations.core.017_300_to_310"] = "kong/db/migrations/core/017_300_to_310.lua",
["kong.db.migrations.core.018_310_to_320"] = "kong/db/migrations/core/018_310_to_320.lua",
["kong.db.migrations.core.019_320_to_330"] = "kong/db/migrations/core/019_320_to_330.lua",
["kong.db.migrations.operations.200_to_210"] = "kong/db/migrations/operations/200_to_210.lua",
["kong.db.migrations.operations.210_to_211"] = "kong/db/migrations/operations/210_to_211.lua",
["kong.db.migrations.operations.212_to_213"] = "kong/db/migrations/operations/212_to_213.lua",
Expand Down
2 changes: 2 additions & 0 deletions kong/db/migrations/core/019_320_to_330.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ return {
ALTER TABLE IF EXISTS ONLY "snis" ADD "updated_at" TIMESTAMP WITH TIME ZONE DEFAULT timezone('UTC'::text, ('now'::text)::timestamp(0) with time zone);
ALTER TABLE IF EXISTS ONLY "targets" ADD "updated_at" TIMESTAMP WITH TIME ZONE DEFAULT timezone('UTC'::text, ('now'::text)::timestamp(0) with time zone);
ALTER TABLE IF EXISTS ONLY "upstreams" ADD "updated_at" TIMESTAMP WITH TIME ZONE DEFAULT timezone('UTC'::text, ('now'::text)::timestamp(0) with time zone);
ALTER TABLE IF EXISTS ONLY "workspaces" ADD "updated_at" TIMESTAMP WITH TIME ZONE DEFAULT timezone('UTC'::text, ('now'::text)::timestamp(0) with time zone);
EXCEPTION WHEN DUPLICATE_COLUMN THEN
-- Do nothing, accept existing state
END;
Expand All @@ -26,6 +27,7 @@ return {
ALTER TABLE snis ADD updated_at timestamp;
ALTER TABLE targets ADD updated_at timestamp;
ALTER TABLE upstreams ADD updated_at timestamp;
ALTER TABLE workspaces ADD updated_at timestamp;
]]
},
}
1 change: 1 addition & 0 deletions kong/db/schema/entities/workspaces.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ return {
{ name = typedefs.utf8_name { required = true, not_one_of = { table.unpack(constants.CORE_ENTITIES) }, } },
{ comment = { type = "string" } },
{ created_at = typedefs.auto_timestamp_s },
{ updated_at = typedefs.auto_timestamp_s },
{ meta = { type = "record", fields = {} } },
{ config = { type = "record", fields = {} } },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ describe("declarative config: flatten", function()
id = "UUID",
tags = null,
created_at = 1234567890,
updated_at = 1234567890,
consumer = null,
service = null,
route = null,
Expand All @@ -299,6 +300,7 @@ describe("declarative config: flatten", function()
id = "UUID",
tags = null,
created_at = 1234567890,
updated_at = 1234567890,
consumer = null,
service = null,
route = null,
Expand Down Expand Up @@ -369,6 +371,7 @@ describe("declarative config: flatten", function()
{
tags = null,
created_at = 1234567890,
updated_at = 1234567890,
custom_id = null,
id = "UUID",
username = "my-consumer",
Expand All @@ -393,6 +396,7 @@ describe("declarative config: flatten", function()
id = "UUID"
},
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "http-log",
Expand All @@ -416,6 +420,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "key-auth",
Expand Down Expand Up @@ -554,6 +559,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "basic-auth",
Expand All @@ -579,6 +585,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "http-log",
Expand All @@ -601,6 +608,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "key-auth",
Expand All @@ -623,6 +631,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "tcp-log",
Expand Down Expand Up @@ -1056,6 +1065,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "basic-auth",
Expand All @@ -1081,6 +1091,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "http-log",
Expand All @@ -1103,6 +1114,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "key-auth",
Expand All @@ -1125,6 +1137,7 @@ describe("declarative config: flatten", function()
},
consumer = null,
created_at = 1234567890,
updated_at = 1234567890,
enabled = true,
id = "UUID",
name = "tcp-log",
Expand Down Expand Up @@ -1247,6 +1260,7 @@ describe("declarative config: flatten", function()
targets = {
{
created_at = 1234567890,
updated_at = 1234567890,
id = "UUID",
tags = null,
target = '127.0.0.1:6661',
Expand All @@ -1255,6 +1269,7 @@ describe("declarative config: flatten", function()
},
{
created_at = 1234567890,
updated_at = 1234567890,
id = "UUID",
tags = null,
target = '127.0.0.1:6661',
Expand Down Expand Up @@ -1300,6 +1315,7 @@ describe("declarative config: flatten", function()
username = 'consumer',
custom_id = null,
created_at = 1234567890,
updated_at = 1234567890,
tags = null,
},
},
Expand All @@ -1323,6 +1339,7 @@ describe("declarative config: flatten", function()
username = 'consumer',
custom_id = null,
created_at = 1234567890,
updated_at = 1234567890,
tags = null,
},
},
Expand Down Expand Up @@ -1360,6 +1377,7 @@ describe("declarative config: flatten", function()
username = 'consumer',
custom_id = null,
created_at = 1234567890,
updated_at = 1234567890,
tags = null,
},
},
Expand Down Expand Up @@ -1426,6 +1444,7 @@ describe("declarative config: flatten", function()
username = 'consumer',
custom_id = null,
created_at = 1234567890,
updated_at = 1234567890,
tags = null,
},
},
Expand Down Expand Up @@ -1492,6 +1511,7 @@ describe("declarative config: flatten", function()
username = 'consumer',
custom_id = null,
created_at = 1234567890,
updated_at = 1234567890,
tags = null,
},
},
Expand Down Expand Up @@ -1557,6 +1577,7 @@ describe("declarative config: flatten", function()
username = 'consumer',
custom_id = null,
created_at = 1234567890,
updated_at = 1234567890,
tags = null,
},
},
Expand Down Expand Up @@ -1716,6 +1737,7 @@ describe("declarative config: flatten", function()
assert.same({
consumers = { {
created_at = 1234567890,
updated_at = 1234567890,
custom_id = null,
id = "UUID",
tags = null,
Expand Down Expand Up @@ -1756,6 +1778,7 @@ describe("declarative config: flatten", function()
assert.same(helpers.deep_sort{
targets = { {
created_at = 1234567890,
updated_at = 1234567890,
id = "UUID",
tags = null,
target = "127.0.0.1:6661",
Expand All @@ -1765,6 +1788,7 @@ describe("declarative config: flatten", function()
weight = 1,
}, {
created_at = 1234567890,
updated_at = 1234567890,
id = "UUID",
tags = null,
target = "127.0.0.1:6661",
Expand All @@ -1777,6 +1801,7 @@ describe("declarative config: flatten", function()
algorithm = "round-robin",
client_certificate = null,
created_at = 1234567890,
updated_at = 1234567890,
hash_fallback = "none",
hash_fallback_header = null,
hash_on = "none",
Expand Down Expand Up @@ -1834,6 +1859,7 @@ describe("declarative config: flatten", function()
algorithm = "round-robin",
client_certificate = null,
created_at = 1234567890,
updated_at = 1234567890,
hash_fallback = "none",
hash_fallback_header = null,
hash_on = "none",
Expand Down Expand Up @@ -1907,6 +1933,7 @@ describe("declarative config: flatten", function()
assert.same({
consumers = { {
created_at = 1234567890,
updated_at = 1234567890,
custom_id = null,
id = "UUID",
tags = null,
Expand All @@ -1933,6 +1960,7 @@ describe("declarative config: flatten", function()
assert.same({
consumers = { {
created_at = 1234567890,
updated_at = 1234567890,
custom_id = null,
id = "UUID",
tags = null,
Expand Down
1 change: 0 additions & 1 deletion spec/02-integration/02-cmd/10-migrations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ for _, strategy in helpers.each_strategy() do
code, stdout, stderr = run_kong("migrations up -f", {
plugins = "bundled"
}, true)
print("stderr: " .. stderr)
assert.equal(0, code)
if strategy ~= "cassandra" then
-- cassandra outputs some warnings on duplicate
Expand Down
15 changes: 12 additions & 3 deletions spec/02-integration/04-admin_api/06-certificates_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ describe("Admin API: #" .. strategy, function()
local body = assert.res_status(200, res)
local json = cjson.decode(body)

certificate.updated_at = nil
json.updated_at = nil

assert.same(certificate, json)
end
end)
Expand All @@ -671,7 +674,8 @@ describe("Admin API: #" .. strategy, function()

local body = assert.res_status(200, res)
local json = cjson.decode(body)

json.updated_at = nil
certificate.updated_at = nil
assert.same(certificate, json)
end
end)
Expand Down Expand Up @@ -754,7 +758,8 @@ describe("Admin API: #" .. strategy, function()

local body = assert.res_status(200, res)
local json = cjson.decode(body)

json.updated_at = nil
certificate.updated_at = nil
assert.same(certificate, json)
end
end)
Expand All @@ -770,7 +775,8 @@ describe("Admin API: #" .. strategy, function()

local body = assert.res_status(200, res)
local json = cjson.decode(body)

json.updated_at = nil
certificate.updated_at = nil
assert.same(certificate, json)
end
end)
Expand Down Expand Up @@ -887,6 +893,7 @@ describe("Admin API: #" .. strategy, function()

-- make sure we did not add any certificate or sni
local json = get_certificates()
json.updated_at = nil
assert.same(json_before, json)
end)

Expand Down Expand Up @@ -934,6 +941,8 @@ describe("Admin API: #" .. strategy, function()

-- make sure we did not add any certificate or sni
local json = get_certificates()
json_before.updated_at = nil
json.update_at = nil
assert.same(json_before, json)
end)

Expand Down
4 changes: 4 additions & 0 deletions spec/02-integration/04-admin_api/08-targets_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,8 @@ describe("Admin API #" .. strategy, function()
assert.response(res).has.status(200)
local json = assert.response(res).has.jsonbody()
json.tags = nil
json.updated_at = nil
target.updated_at = nil
assert.same(target, json)
end)
end)
Expand Down Expand Up @@ -917,6 +919,8 @@ describe("Admin API #" .. strategy, function()
assert.response(res).has.status(200)
local json = assert.response(res).has.jsonbody()
json.tags = nil
json.updated_at = nil
target.updated_at = nil
assert.same(target, json)
end)

Expand Down
15 changes: 8 additions & 7 deletions spec/05-migration/db/migrations/core/019_320_to_330_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ local uh = require "spec/upgrade_helpers"

describe("database migration", function()
uh.old_after_up("has created the expected new columns", function()
assert.table_has_column("ca_certificates", "updated_at", "timestamp")
assert.table_has_column("certificates", "updated_at", "timestamp")
assert.table_has_column("consumers", "updated_at", "timestamp")
assert.table_has_column("plugins", "updated_at", "timestamp")
assert.table_has_column("snis", "updated_at", "timestamp")
assert.table_has_column("targets", "updated_at", "timestamp")
assert.table_has_column("upstreams", "updated_at", "timestamp")
assert.table_has_column("ca_certificates", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("certificates", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("consumers", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("plugins", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("snis", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("targets", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("upstreams", "updated_at", "timestamp with time zone", "timestamp")
assert.table_has_column("workspaces", "updated_at", "timestamp with time zone", "timestamp")
end)
end)

0 comments on commit ab74ca3

Please sign in to comment.