## Configuration

Add database configuration to your config file:

```yaml
database:
  maxOpenConns: 25
  maxIdleConns: 5
  tlsMode: skip-verify
```

## Setup

1. **Create Database**: Create the MySQL database specified in your config
2. **Schema Initialization**: The tables will be created automatically when the application starts using the embedded schema
3. **Configure Connection**: Update your config file with proper database credentials

## Schema Management

This package uses two approaches for database schema management:

### 1. Complete Schema (`schema.sql`)
- **Purpose**: Contains the complete current database schema
- **Location**: `internal/db/mysql/schema.sql` 
- **Usage**: Embedded in Go binary for initial setup and testing
- **When to use**: Development, testing, fresh deployments

### 2. Migration Files (`internal/db/migrations/`)
- **Purpose**: Incremental database changes over time
- **Location**: `internal/db/migrations/001_create_workload_tests.sql` (and future migration files)
- **Usage**: For production deployments with proper migration tools
- **When to use**: Production upgrades, database versioning

#### Using Migration Tools (Future)

```bash
# Example with golang-migrate
migrate -database "mysql://user:password@tcp(host:port)/database" -path internal/db/migrations up
```

The migration files in `internal/db/migrations/` are designed to work with standard migration tools.

## Connection Management

The implementation uses `sqlx.DB` with:
- Connection pooling (configurable max open/idle connections)
- Connection lifetime management
- Proper connection testing and health checking

## Testing

### Test Isolation Strategy

The test suite implements **complete database isolation** for parallel test execution:

- **Unique Database Per Test**: Each test creates its own uniquely named database (e.g., `tidbcloud_pov_test_a1b2c3d4_1234567890`)
- **No Shared State**: Tests can run in parallel without interfering with each other
- **Automatic Cleanup**: Test databases are automatically dropped after each test completes
- **Parallel Safe**: Multiple tests can run simultaneously without conflicts

### Running Tests

```bash
# Run all tests (integration tests require MySQL server)
go test ./internal/db/mysql/...

# Run with verbose output
go test -v ./internal/db/mysql/...
```
