diff options
| author | Bobby <[email protected]> | 2026-03-08 02:27:15 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-08 02:27:15 +0530 |
| commit | cca905d35412f1549400fc3d1aca6dc704d8cae6 (patch) | |
| tree | 0c0231f5c2ebaeb7700e08a2c1f07373d3251658 /database | |
| parent | 547384c41181c034a5eaf340c5e569d36eb013be (diff) | |
| download | dove-cca905d35412f1549400fc3d1aca6dc704d8cae6.tar.xz dove-cca905d35412f1549400fc3d1aca6dc704d8cae6.zip | |
feat(domains): add new TLD creation page and update sidebar
- Introduced a new HTMX template for creating TLDs.
- Created a new Django template for the new TLD page.
- Updated the sidebar to include a link to the domains section.
refactor(types): remove unused types and consolidate request handling
- Deleted unused type definitions related to authentication, errors, mailboxes, overview, requests, responses, and users.
- Introduced a new collections package for generic data structures.
- Refactored request handling to use a more streamlined approach with RequestInfo and Param types.
fix(meta): improve pagination and sorting functionality
- Updated pagination logic to handle default values and edge cases.
- Introduced a new Sorting type for better sorting management in queries.
chore(urls): refactor URL handling and registry
- Replaced enums with string constants for HTTP methods.
- Consolidated route registration logic and improved type safety with RegisteredRoute.
style(shortcuts): clean up error handling and rendering functions
- Enhanced error handling functions for better readability and maintainability.
- Removed deprecated functions and improved the structure of rendering logic.
Diffstat (limited to 'database')
| -rw-r--r-- | database/constants.go | 11 | ||||
| -rw-r--r-- | database/database.go | 13 | ||||
| -rw-r--r-- | database/defaults.go | 11 | ||||
| -rw-r--r-- | database/functions.go | 2 | ||||
| -rw-r--r-- | database/messages.go | 8 | ||||
| -rw-r--r-- | database/migration.go | 6 |
6 files changed, 30 insertions, 21 deletions
diff --git a/database/constants.go b/database/constants.go deleted file mode 100644 index e16dcde..0000000 --- a/database/constants.go +++ /dev/null @@ -1,11 +0,0 @@ -package database - -import "time" - -const ( - DATABASE_FILE_NAME = "dove.db" - LOG_PREFIX = "Database" - MAX_IDLE_CONNECTIONS = 5 - MAX_OPEN_CONNECTIONS = 25 - MAX_CONNECTION_LIFETIME = time.Hour -) diff --git a/database/database.go b/database/database.go index ac06c98..888388c 100644 --- a/database/database.go +++ b/database/database.go @@ -1,7 +1,6 @@ package database import ( - "dove/messages" "dove/utils/logger" "gorm.io/driver/sqlite" @@ -20,19 +19,19 @@ func init() { }) if connectionError != nil { - logger.Fatalf(LOG_PREFIX, messages.DatabaseConnectionFailed, connectionError) + logger.Fatalf(LogPrefix, ConnectionFailed, connectionError) } sqlDB, poolError := DB.DB() if poolError != nil { - logger.Fatalf(LOG_PREFIX, messages.DatabasePoolConfigFailed, poolError) + logger.Fatalf(LogPrefix, PoolConfigFailed, poolError) } - sqlDB.SetMaxOpenConns(MAX_OPEN_CONNECTIONS) - sqlDB.SetMaxIdleConns(MAX_IDLE_CONNECTIONS) - sqlDB.SetConnMaxLifetime(MAX_CONNECTION_LIFETIME) + sqlDB.SetMaxOpenConns(MaxOpenConnections) + sqlDB.SetMaxIdleConns(MaxIdleConnections) + sqlDB.SetConnMaxLifetime(MaxConnectionLifetime) - logger.Successf(LOG_PREFIX, messages.DatabaseConnected, databaseDSN) + logger.Successf(LogPrefix, Connected, databaseDSN) migrate() } diff --git a/database/defaults.go b/database/defaults.go new file mode 100644 index 0000000..821509b --- /dev/null +++ b/database/defaults.go @@ -0,0 +1,11 @@ +package database + +import "time" + +const ( + FileName = "dove.db" + LogPrefix = "Database" + MaxConnectionLifetime = time.Hour + MaxIdleConnections = 5 + MaxOpenConnections = 25 +) diff --git a/database/functions.go b/database/functions.go index 71723ca..09d6ae4 100644 --- a/database/functions.go +++ b/database/functions.go @@ -9,7 +9,7 @@ import ( ) func resolveDatabasePath() string { - return filepath.Join(config.DataDir, DATABASE_FILE_NAME) + return filepath.Join(config.DataDir, FileName) } func resolveGORMLogLevel() logger.Interface { diff --git a/database/messages.go b/database/messages.go new file mode 100644 index 0000000..2c51076 --- /dev/null +++ b/database/messages.go @@ -0,0 +1,8 @@ +package database + +const ( + Connected = "Connected to %s." + ConnectionFailed = "Failed to connect to database: %v" + MigrationFailed = "Failed to run database migrations: %v" + PoolConfigFailed = "Failed to configure connection pool: %v" +) diff --git a/database/migration.go b/database/migration.go index 4d8363c..e18f2d6 100644 --- a/database/migration.go +++ b/database/migration.go @@ -1,13 +1,15 @@ package database import ( - "dove/messages" "dove/models" + "dove/models/domain" "dove/utils/logger" ) func migrate() { migrationError := DB.AutoMigrate( + &domain.TLD{}, + &domain.Domain{}, &models.User{}, &models.Mailbox{}, &models.Alias{}, @@ -17,6 +19,6 @@ func migrate() { ) if migrationError != nil { - logger.Fatalf(LOG_PREFIX, messages.DatabaseMigrationFailed, migrationError) + logger.Fatalf(LogPrefix, MigrationFailed, migrationError) } } |
