Skip to content

feat: postgres database integration#27

Open
Vuks69 wants to merge 2 commits into
Neon-Genesis-Linux:mainfrom
Vuks69:postgres
Open

feat: postgres database integration#27
Vuks69 wants to merge 2 commits into
Neon-Genesis-Linux:mainfrom
Vuks69:postgres

Conversation

@Vuks69
Copy link
Copy Markdown
Member

@Vuks69 Vuks69 commented May 21, 2026

Summary

  • Postgres database layer with connection pooling, env-var-based config, migrations, and CRUD operations for guilds, users, moderation logs, and caching
  • In-memory cache
  • Migration runner with atomic per-file transactions and embedded SQL migration files
  • Background DB connection — gateway starts first, DB connects with retry in background (bot stays online if PG is down)
  • Unit tests for cache (set/get/expiry/concurrency), command dispatch (exact match/bot filter/prefix), and env helper functions
  • Docker compose with Postgres 16 service and healthcheck

Files changed

New

  • internal/db/ — connection, migrations, cache, guild, user, moderation, types
  • internal/db/migrations/001_init_schema.sql — initial schema (guilds, users, moderation_logs)
  • internal/db/cache_test.go, internal/core/start_test.go, internal/db/connection_test.go

Modified

  • internal/core/start.go — background DB init, context-aware shutdown, recover on goroutines
  • internal/community/commands.go — adapted to new structure
  • docker-compose.yml — added postgres service
  • .env.example — DB configuration vars
  • go.mod / go.sum — added lib/pq dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant