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 8fe43da18d71..5659cdf72ef2 100644 --- a/spec/internal/db.lua +++ b/spec/internal/db.lua @@ -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 @@ -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