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

tests(db): Always do schema reset in get_db_utils #13808

Merged
merged 3 commits into from
Oct 30, 2024
Merged
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
5 changes: 0 additions & 5 deletions spec/02-integration/03-db/08-declarative_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ for _, strategy in helpers.each_strategy() do
local _
_, db = helpers.get_db_utils(strategy)

-- This is a special case, where some DB states could be corrupted by DB truncation in `lazy_teardown()`.
-- We manually bootstrap the DB here to ensure the creation of a table is done correctly
db:schema_reset()
helpers.bootstrap_database(db)

_G.kong.db = db
assert(helpers.start_kong({
database = strategy,
Expand Down
4 changes: 4 additions & 0 deletions spec/internal/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ end

local function bootstrap_database(db)
local schema_state = assert(db:schema_state())

if schema_state.needs_bootstrap then
assert(db:schema_bootstrap())
schema_state = assert(db:schema_state())
end

if schema_state.new_migrations then
Expand Down Expand Up @@ -313,6 +315,8 @@ local function get_db_utils(strategy, tables, plugins, vaults, skip_migrations)
assert(db:init_connector())

if not skip_migrations then
-- Drop all schema and data
assert(db:schema_reset())
bootstrap_database(db)
end

Expand Down
Loading