initiate repo

This commit is contained in:
renaldybrada
2026-01-27 11:41:51 +07:00
commit ccf12a95b1
33 changed files with 8209 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
package database
import (
"antrian-operasi/internal/config"
"database/sql"
"fmt"
)
func (s *service) openSQLiteConnection(config config.DatabaseConfig) (*sql.DB, error) {
// Open connection
db, err := sql.Open("sqlite3", config.Path)
if err != nil {
return nil, fmt.Errorf("failed to open SQLite connection: %w", err)
}
// Enable foreign key constraints and WAL mode for better security and performance
_, err = db.Exec("PRAGMA foreign_keys = ON; PRAGMA journal_mode = WAL;")
if err != nil {
return nil, fmt.Errorf("failed to configure SQLite: %w", err)
}
return db, nil
}