mirror of
https://github.com/get-drexa/drive.git
synced 2025-11-30 21:41:39 +00:00
- read database config from config file - rename migration file to expected file name format
38 lines
791 B
Go
38 lines
791 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/get-drexa/drexa/internal/database"
|
|
"github.com/get-drexa/drexa/internal/drexa"
|
|
)
|
|
|
|
func main() {
|
|
configPath := flag.String("config", "", "path to config file (required)")
|
|
flag.Parse()
|
|
|
|
if *configPath == "" {
|
|
fmt.Fprintln(os.Stderr, "error: --config is required")
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
config, err := drexa.ConfigFromFile(*configPath)
|
|
if err != nil {
|
|
log.Fatalf("failed to load config: %v", err)
|
|
}
|
|
|
|
db := database.NewFromPostgres(config.Database.PostgresURL)
|
|
defer db.Close()
|
|
|
|
log.Println("running migrations...")
|
|
if err := database.RunMigrations(context.Background(), db); err != nil {
|
|
log.Fatalf("failed to run migrations: %v", err)
|
|
}
|
|
log.Println("migrations completed successfully")
|
|
}
|