Database
The scaffold supports three database drivers via GORM.
Supported Drivers
| Driver | Best For | Config |
|---|---|---|
| SQLite | Development, small projects | Zero config, file-based |
| MySQL | Production, existing MySQL infra | Requires running MySQL server |
| PostgreSQL | Production, advanced features | Requires running PostgreSQL server |
Configuration
In config.yaml:
yaml
database:
driver: sqlite # sqlite / mysql / postgres
dsn: data.db # Connection stringDSN Examples
SQLite:
yaml
dsn: data.dbMySQL:
yaml
dsn: root:password@tcp(127.0.0.1:3306)/mydb?charset=utf8mb4&parseTime=True&loc=LocalPostgreSQL:
yaml
dsn: host=127.0.0.1 user=postgres password=123456 dbname=mydb port=5432 sslmode=disableDocker Compose
The generated project includes a docker-compose.yaml with pre-configured services:
bash
# Start MySQL
docker compose up -d mysql
# Start PostgreSQL
docker compose up -d postgres
# Start Redis
docker compose up -d redisAuto Migration
GORM's AutoMigrate runs at startup, creating tables automatically. Add new models in internal/models/ and register them in db.go.