Feature/postgre#375
Conversation
Co-authored-by: Copilot <copilot@github.com>
🚀 Deploy this PRTo deploy this branch to the dev environment, go to the Deploy PR to Dev workflow and click Run workflow with this PR number. This will build a Docker image from your branch, push it to GHCR, and trigger an ArgoCD sync. |
There was a problem hiding this comment.
Pull request overview
This PR migrates the bot’s database layer and deployment configuration from MySQL to PostgreSQL (including updated connection strings, K8s manifests, and Docker Compose), and replaces the MySQL EVENT-based karma reset mechanism with an in-app scheduled service.
Changes:
- Switched DB connectivity from MySql.Data/MySqlConnection to Npgsql + Insight.Database PostgreSQL provider and updated SQL for PostgreSQL.
- Added
KarmaResetServiceto handle weekly/monthly/yearly karma resets (replacing MySQL EVENT scheduler). - Updated dev/prod Kubernetes manifests, secrets, and docs to use PostgreSQL + pgAdmin and added PostgreSQL backup manifests.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates documentation for PostgreSQL setup and formatting adjustments. |
| k8s/prod/postgresql.yaml | Replaces MySQL Deployment/Service/PVC with PostgreSQL equivalents in prod. |
| k8s/prod/postgresql-backup.yaml | Adds a PostgreSQL backup Deployment for prod. |
| k8s/prod/pgadmin.yaml | Replaces phpMyAdmin with pgAdmin in prod. |
| k8s/prod/mysql-backup.yaml | Removes the MySQL backup Deployment from prod. |
| k8s/prod/external-secrets.yaml | Renames MySQL secrets to PostgreSQL + adds pgAdmin credentials secret in prod. |
| k8s/prod/bot.yaml | Updates bot DB secret ref and init container to wait for PostgreSQL in prod. |
| k8s/prod/bot-config.yaml | Updates prod Settings.json connection string to PostgreSQL. |
| k8s/dev/postgresql.yaml | Replaces MySQL Deployment/Service/PVC with PostgreSQL equivalents in dev. |
| k8s/dev/postgresql-backup.yaml | Adds a PostgreSQL backup Deployment for dev. |
| k8s/dev/pgadmin.yaml | Replaces phpMyAdmin with pgAdmin in dev. |
| k8s/dev/mysql-backup.yaml | Removes the MySQL backup Deployment from dev. |
| k8s/dev/external-secrets.yaml | Renames MySQL secrets to PostgreSQL + adds pgAdmin credentials secret in dev. |
| k8s/dev/bot.yaml | Updates bot DB secret ref and init container to wait for PostgreSQL in dev. |
| k8s/dev/bot-config.yaml | Updates dev Settings.json connection string to PostgreSQL. |
| docs/plans/done/mysql-to-postgresql-migration.md | Adds a “done” migration plan/summary document. |
| docker-compose.yml | Switches local dev stack from MySQL + phpMyAdmin to PostgreSQL + pgAdmin. |
| DiscordBot/Settings/Settings.example.json | Updates example DB connection string for PostgreSQL. |
| DiscordBot/Services/KarmaResetService.cs | Adds polling-based karma reset scheduler + meta table tracking. |
| DiscordBot/Services/DatabaseService.cs | Switches DB connections to Npgsql and rewrites schema creation for PostgreSQL. |
| DiscordBot/Program.cs | Registers and eagerly resolves KarmaResetService. |
| DiscordBot/Modules/ModerationModule.cs | Removes unused BouncyCastle import and minor formatting. |
| DiscordBot/Extensions/UserDBRepository.cs | Updates INSERT patterns and rank ordering for PostgreSQL. |
| DiscordBot/Extensions/DBConnectionExtension.cs | Replaces SHOW COLUMNS with information_schema query. |
| DiscordBot/Extensions/CasinoRepository.cs | Updates INSERT patterns and JSON handling for PostgreSQL. |
| DiscordBot/DiscordBot.csproj | Removes MySql.Data and adds Insight.Database PostgreSQL provider package. |
Comments suppressed due to low confidence (1)
DiscordBot/Extensions/CasinoRepository.cs:16
- Same identifier-casing issue as ServerUserRepo: these queries use unquoted identifiers from CasinoProps, but DatabaseService creates the casino tables with quoted mixed-case column names. In PostgreSQL, unquoted identifiers are folded to lowercase and won't match quoted mixed-case columns; align schema + query quoting/casing consistently.
[Sql($@"
INSERT INTO {CasinoProps.CasinoTableName} ({CasinoProps.UserID}, {CasinoProps.Tokens}, {CasinoProps.CreatedAt}, {CasinoProps.UpdatedAt}, {CasinoProps.LastDailyReward})
VALUES (@{CasinoProps.UserID}, @{CasinoProps.Tokens}, @{CasinoProps.CreatedAt}, @{CasinoProps.UpdatedAt}, @{CasinoProps.LastDailyReward})
RETURNING *")]
Task<CasinoUser> InsertCasinoUser(CasinoUser user);
[Sql($"SELECT * FROM {CasinoProps.CasinoTableName} WHERE {CasinoProps.UserID} = @userId")]
Task<CasinoUser> GetCasinoUser(string userId);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
# Conflicts: # README.md
|
/build |
|
🐳 Build complete! Image: To deploy with manifest changes:
|
Co-authored-by: Copilot <copilot@github.com>
|
/build |
|
🐳 Build complete! Image: To deploy with manifest changes:
|
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…ntials Co-authored-by: Copilot <copilot@github.com>
…eserve data during migration - Rename TransactionType enum to TransactionKind (avoids DB column name collision) - Replace Type (integer) column with TransactionType (varchar) to match MySQL - Replace DetailsJson (jsonb) column with Description (text) to match MySQL - Add TargetUserID column for migration compatibility - Update CasinoProps constants, repository SQL, and all consumer references
- Create mysql-to-postgresql-changes.md with full schema, code, and infra details - Update data-migration-mysql-to-postgresql.md with working pgloader config - Delete outdated mysql-to-postgresql-migration.md summary - Update docs/INDEX.md with new doc links
- Add token_transactions to table matching regex (dev + prod) - Add BEFORE LOAD: DROP+CREATE token_transactions with MySQL-compatible schema - Ensures existing PG tables with old column names are replaced before import
|
/build |
|
🐳 Build complete! Image: To deploy with manifest changes:
|
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
No description provided.