refactor(controlplane,dataplane): migrate jobs and feature flags from postgres to sqlc#2622
refactor(controlplane,dataplane): migrate jobs and feature flags from postgres to sqlc#2622
Conversation
Migrate the last remaining database/postgres/ repository implementations to sqlc-based modules under internal/, completing the postgres-to-sqlc migration. - Create internal/jobs/ with sqlc queries, Service implementing datastore.JobRepository (9 methods), and comprehensive tests - Create internal/feature_flags/ with sqlc queries across 3 tables (feature_flags, feature_flag_overrides, early_adopter_features), Service implementing both fflag.FeatureFlagFetcher and fflag.EarlyAdopterFeatureFetcher, and comprehensive tests - Update all call sites: dataplane worker, server init, API handlers, CLI utilities, and test files - Delete database/postgres/job.go, feature_flag.go, feature_flag_fetcher.go, early_adopter_feature_fetcher.go
|
@cursoragent bugbot review |
|
The GitHub CLI doesn't have write access to post comments. I'll provide the full review here instead. Bug Review — PR #2622Overall assessment: The migration is well-structured and functionally complete. The project compiles cleanly ( Issues Found1. [Medium] 2. [Medium] 3. [Low] 4. [Low] Cursor comparison uses string ordering — Things Done Well
|
Replace direct instantiation of feature flag service with centralized `FeatureFlagService` in application context. Update relevant API handlers for consistency.
…xplicit Replaced the default package-level logger (`pkgLogger`) in the postgres module with explicit logger injection. Updated affected functions to accept and use the logger parameter consistently.
- Replace `COALESCE(COUNT(DISTINCT(id)), 0)` with `COUNT(id)` in job count queries for consistency and clarity. - Remove unused `ErrJobNotCreated` constant from `impl.go`.
- Deleted `postgres_test.go` as it no longer aligns with the current database structure and testing strategy.
…mmands - Updated `postgres.NewDB` calls to explicitly pass logger instances across CLI utilities and migration commands. - Replaced package-level log usage with `a.Logger` for consistent logging. - Improved logging in migration commands (`up`, `down`, `create`) and other utilities.
- Inject logger into CLI initialization and migrate commands for consistent logging. - Replace `Run` with `RunE` in Cobra commands to standardize error propagation. - Remove `os.Exit` calls in favor of returning errors for better control flow.


Migrate the last remaining database/postgres/ repository implementations to sqlc-based modules under internal/, completing the postgres-to-sqlc migration.