From b9e6e55265b590fd1eb3679565a7f844d3f1c2ae Mon Sep 17 00:00:00 2001 From: Shiroko Date: Wed, 30 Oct 2024 09:47:02 +0800 Subject: [PATCH] tests(db): move the db:schema_reset to get_db_utils to allow some special use cases. --- spec/02-integration/03-db/08-declarative_spec.lua | 5 ----- spec/internal/db.lua | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/spec/02-integration/03-db/08-declarative_spec.lua b/spec/02-integration/03-db/08-declarative_spec.lua index 9c6b80af2e1c..ffe8d74b4e9f 100644 --- a/spec/02-integration/03-db/08-declarative_spec.lua +++ b/spec/02-integration/03-db/08-declarative_spec.lua @@ -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, diff --git a/spec/internal/db.lua b/spec/internal/db.lua index 57761d1f3bec..5659cdf72ef2 100644 --- a/spec/internal/db.lua +++ b/spec/internal/db.lua @@ -215,8 +215,6 @@ end local function bootstrap_database(db) - -- Drop all schema and data - assert(db:schema_reset()) local schema_state = assert(db:schema_state()) if schema_state.needs_bootstrap then @@ -317,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