-
Notifications
You must be signed in to change notification settings - Fork 25
Architecture Improvements [MYSQL + POSTGRESQL DB SUPPORT] #122
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the database connection logic to support multiple database providers (MySQL and PostgreSQL) through a provider pattern, replacing the monolithic MySQL-only implementation.
- Introduced a
DBProviderinterface with MySQL and PostgreSQL implementations - Refactored database connection logic to use dependency injection via the provider pattern
- Added PostgreSQL driver support alongside the existing MySQL driver
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/infrastructure/db_provider.go | Defines the DBProvider interface and factory function for selecting the appropriate database provider based on configuration |
| pkg/infrastructure/postgres_provider.go | Implements the DBProvider interface for PostgreSQL connections |
| pkg/infrastructure/mysql_provider.go | Implements the DBProvider interface for MySQL connections |
| pkg/infrastructure/database_factory.go | Provides Fx constructors for dependency injection of database providers and connections |
| pkg/infrastructure/db.go | Refactored connection logic into separate MySQLConnect and PostgresConnect functions with proper error handling |
| pkg/infrastructure/module.go | Registers the new NewDBProvider constructor in the Fx module |
| go.mod | Promotes gorm.io/driver/postgres from indirect to direct dependency and moves go-sql-driver/mysql to indirect |
| go.sum | Updates checksums for new and modified dependencies |
| .env.example | Documents postgres as a supported DB_TYPE option |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
[WIP] Update database provider interface based on feedback
[WIP] Update implementation based on feedback for database provider interface
This comment was marked as outdated.
This comment was marked as outdated.
…-one [WIP] Address feedback on database provider interface implementation
|
@Denes-cilwal I've opened a new pull request, #127, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Denes-cilwal <[email protected]>
Co-authored-by: Denes-cilwal <[email protected]>
…-one [WIP] Address feedback on database provider interface implementation
|
Closes #120 |
|
This branch provides support for both MySQL and PostgreSQL. |
This pull request introduces support for PostgreSQL as a database option in addition to MySQL, refactoring the database connection logic to use a provider-based architecture. The changes improve modularity and future extensibility, allowing easy addition of new database types. The most important changes are grouped below:
Database provider architecture:
DBProviderinterface and provider factory inpkg/infrastructure/db_provider.go, enabling dynamic selection of MySQL or PostgreSQL based on theDB_TYPEenvironment variable.MySQLProviderandPostgresProviderin separate files (pkg/infrastructure/mysql_provider.goandpkg/infrastructure/postgres_provider.go) to encapsulate connection logic for each database type. [1] [2]pkg/infrastructure/database_factory.goto use the provider pattern for database creation, replacing direct instantiation with provider-based construction.PostgreSQL support:
pkg/infrastructure/db.go, including database existence checks and dynamic SSL mode selection.go.mod) to includegorm.io/driver/postgresand adjust indirect dependencies for both MySQL and PostgreSQL. [1] [2] [3]Configuration and integration:
.env.exampleto document support for both MySQL and PostgreSQL in theDB_TYPEvariable.pkg/infrastructure/module.go).pkg/infrastructure/db.go.… support