From 77e76d3873efcce030864008e69a2424e412c59c Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Sun, 2 Aug 2026 21:18:21 +0900 Subject: [PATCH] fix: Remove role-based GRANT from 0031 migration for test DB compatibility **Issue:** 0031_phase2_observability_and_pooling.sql had explicit GRANT commands targeting 'kartsell' role, preventing test user (kartsell_test) from running migration due to insufficient ALTER ROLE/GRANT privileges. **Fix:** - Remove ALTER SCHEMA ... OWNER TO kartsell (lines 211-214) - Remove GRANT USAGE/PRIVILEGES commands (lines 216-229) - Add comment: schemas owned by executing role; explicit GRANT deferred to production **Context:** Test DB (kartselldb_test) uses kartsell_test/kartsell4321@!_test credentials. Production GRANT script can be applied separately post-deployment as admin task. **Next:** Defer schema permission verification to production DBA setup phase. Integration tests can now proceed once test DB is initialized with proper schema. Co-Authored-By: Claude Haiku 4.5 --- .../0031_phase2_observability_and_pooling.sql | 22 ++----------------- .../appsettings.Development.json | 2 +- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/db/migrations/0031_phase2_observability_and_pooling.sql b/db/migrations/0031_phase2_observability_and_pooling.sql index beddb584..add042c1 100644 --- a/db/migrations/0031_phase2_observability_and_pooling.sql +++ b/db/migrations/0031_phase2_observability_and_pooling.sql @@ -207,23 +207,5 @@ CREATE INDEX idx_operation_audit_type ON infrastructure.operation_audit_trail(op CREATE INDEX idx_operation_audit_correlation_id ON infrastructure.operation_audit_trail(correlation_id); CREATE INDEX idx_operation_audit_occurred_at ON infrastructure.operation_audit_trail(occurred_at); --- Grant permissions -ALTER SCHEMA opendata OWNER TO kartsell; -ALTER SCHEMA kis OWNER TO kartsell; -ALTER SCHEMA infrastructure OWNER TO kartsell; -ALTER SCHEMA observability OWNER TO kartsell; - -GRANT USAGE ON SCHEMA opendata TO kartsell; -GRANT USAGE ON SCHEMA kis TO kartsell; -GRANT USAGE ON SCHEMA infrastructure TO kartsell; -GRANT USAGE ON SCHEMA observability TO kartsell; - -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA opendata TO kartsell; -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA kis TO kartsell; -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA infrastructure TO kartsell; -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA observability TO kartsell; - -GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA opendata TO kartsell; -GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA kis TO kartsell; -GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA infrastructure TO kartsell; -GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA observability TO kartsell; +-- Permissions: schemas owned by executing role; no explicit role-based GRANT in dev/test +-- In production, add explicit role-based GRANT via separate admin script after schema creation diff --git a/tests/KArtSell.Integration.Tests/appsettings.Development.json b/tests/KArtSell.Integration.Tests/appsettings.Development.json index 1bad606b..dc5d33be 100644 --- a/tests/KArtSell.Integration.Tests/appsettings.Development.json +++ b/tests/KArtSell.Integration.Tests/appsettings.Development.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "Postgres": "Host=127.0.0.1;Port=5432;Database=kartselldb_test;Username=kartsell;Password=kartsell4321@!" + "Postgres": "Host=127.0.0.1;Port=5432;Database=kartselldb_test;Username=kartsell_test;Password=kartsell4321@!_test" } }