2023-08-04 13:34:18 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2025-03-23 23:09:47 +01:00
|
|
|
// SupportedDatabase is a type for the supported database types.
|
|
|
|
// Supported: mysql, mssql, postgres, sqlite
|
2023-08-04 13:34:18 +02:00
|
|
|
type SupportedDatabase string
|
|
|
|
|
|
|
|
const (
|
|
|
|
DatabaseMySQL SupportedDatabase = "mysql"
|
|
|
|
DatabaseMsSQL SupportedDatabase = "mssql"
|
|
|
|
DatabasePostgres SupportedDatabase = "postgres"
|
|
|
|
DatabaseSQLite SupportedDatabase = "sqlite"
|
|
|
|
)
|
|
|
|
|
2025-03-23 23:09:47 +01:00
|
|
|
// DatabaseConfig contains the configuration for the database connection.
|
2023-08-04 13:34:18 +02:00
|
|
|
type DatabaseConfig struct {
|
2025-02-28 16:11:55 +01:00
|
|
|
// Debug enables logging of all database statements
|
|
|
|
Debug bool `yaml:"debug"`
|
|
|
|
// SlowQueryThreshold enables logging of slow queries which take longer than the specified duration
|
|
|
|
SlowQueryThreshold time.Duration `yaml:"slow_query_threshold"` // 0 means no logging of slow queries
|
|
|
|
// Type is the database type. Supported: mysql, mssql, postgres, sqlite
|
|
|
|
Type SupportedDatabase `yaml:"type"`
|
|
|
|
// DSN is the database connection string.
|
|
|
|
// For SQLite, it is the path to the database file.
|
|
|
|
// For other databases, it is the connection string, see: https://gorm.io/docs/connecting_to_the_database.html
|
|
|
|
DSN string `yaml:"dsn"`
|
2023-08-04 13:34:18 +02:00
|
|
|
}
|