Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(migrations) implement post up and teardown functionality in connectors #3957

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions kong/db/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,14 @@ do
end
end

if run_teardown then
ok, err = self.connector:post_run_teardown_migrations()
if not ok then
self.connector:close()
return nil, prefix_err(self, err)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When both run_up and run_teardown are given, this will wait for schema consensus twice (and print the verbose logs twice as well). Will update locally.


self.connector:close()

return true
Expand Down
12 changes: 11 additions & 1 deletion kong/db/strategies/cassandra/connector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,17 @@ do
end


function CassandraConnector:post_up_migrations()
function CassandraConnector:post_run_up_migrations()
local ok, err = wait_for_schema_consensus(self)
if not ok then
return nil, err
end

return true
end


function CassandraConnector:post_run_teardown_migrations()
local ok, err = wait_for_schema_consensus(self)
if not ok then
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions kong/db/strategies/connector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ function Connector:post_run_up_migrations()
end


function Connector:post_run_teardown_migrations()
return true
end


function Connector:record_migration()
error(fmt("record_migration() not implemented for '%s' strategy",
self.database))
Expand Down
7 changes: 6 additions & 1 deletion kong/db/strategies/postgres/connector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,12 @@ function _mt:record_migration(subsystem, name, state)
end


function _mt:post_up_migrations()
function _mt:post_run_up_migrations()
return true
end


function _mt:post_run_teardown_migrations()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably not bother with those since the parent class defines these... Will update as well.

return true
end

Expand Down