1.7 KiB
1.7 KiB
1. Dependencies
- 1.1 Remove
github.com/mattn/go-sqlite3from go.mod - 1.2 Add
github.com/jackc/pgx/v5to go.mod - 1.3 Run
go mod tidyto clean up dependencies
2. Database Connection
- 2.1 Update
internal/db/database.goto importpgx/v5/stdliband register the driver - 2.2 Remove SQLite-specific
isRetryableErrorandretryOperationfunctions - 2.3 Update
openAndConfigureDBto usepgxdriver name and remove directory creation logic - 2.4 Update
DefaultDBConfigto use a PostgreSQL DSN default (e.g.,postgres://localhost:5432/member_console) - 2.5 Simplify
ConnectandConnectAndMigrateto remove retry logic wrapper
3. Migrations
- 3.1 Delete existing SQLite migration files in
internal/db/migrations/ - 3.2 Create fresh PostgreSQL migration
00001_init.sqlwith users, sites, payments tables - 3.3 Use SERIAL for primary keys, PostgreSQL timestamp types, and proper trigger syntax
- 3.4 Update
internal/db/migrations.goto set goose dialect to "postgres"
4. sqlc Configuration
- 4.1 Update
internal/db/sqlc.yamlto useengine: "postgresql" - 4.2 Update SQL queries in
internal/db/queries/for PostgreSQL syntax (e.g.,$1instead of?) - 4.3 Run
sqlc generateto regenerate Go code
5. Development Environment
- 5.1 Add PostgreSQL service to docker-compose.yml (if exists) or create one
- 5.2 Update
--db-dsnflag default and help text incmd/start.go
6. Verification
- 6.1 Run the application against a local PostgreSQL instance
- 6.2 Verify migrations apply successfully
- 6.3 Test basic CRUD operations for users, sites, and payments