Added workouts database schema #25

Merged
robin merged 9 commits from dev into main 2026-08-28 14:47:14 +02:00
3 changed files with 10 additions and 6 deletions
Showing only changes of commit 2732038a1f - Show all commits
+2 -1
View File
@@ -11,6 +11,7 @@ import (
"github.com/joho/godotenv"
"github.com/robindittmar/dttmr-api/internal/config"
"github.com/robindittmar/dttmr-api/internal/database"
"github.com/robindittmar/dttmr-api/internal/database/migrations"
"github.com/robindittmar/dttmr-api/internal/domain"
"github.com/robindittmar/dttmr-api/internal/repository"
)
@@ -51,7 +52,7 @@ func main() {
}
}()
if err := database.RunMigrations(db); err != nil {
if err := database.RunMigrations(db, migrations.MigrationFS); err != nil {
slog.Error("failed to run migrations", slog.Any("error", err))
os.Exit(1)
}
+2 -5
View File
@@ -2,9 +2,9 @@ package database
import (
"database/sql"
"embed"
"errors"
"fmt"
"io/fs"
"log/slog"
"github.com/golang-migrate/migrate/v4"
@@ -12,10 +12,7 @@ import (
"github.com/golang-migrate/migrate/v4/source/iofs"
)
//go:embed migrations/*.sql
var migrationFS embed.FS
func RunMigrations(db *sql.DB) error {
func RunMigrations(db *sql.DB, migrationFS fs.FS) error {
sourceDriver, err := iofs.New(migrationFS, "migrations")
if err != nil {
return fmt.Errorf("failed to load embedded migrations: %w", err)
+6
View File
@@ -0,0 +1,6 @@
package migrations
import "embed"
//go:embed *.sql
var MigrationFS embed.FS