refactor: group migration graph logic

This commit is contained in:
Marc 2024-07-11 20:07:12 -04:00
parent e68ded1b3c
commit 88db84cac4
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 9 additions and 9 deletions

View file

@ -5,6 +5,15 @@ import (
"fmt"
)
type MigrationGraph struct {
// Reference to the root of the graph.
Root *Migration
// Name to struct mapping of all migrations part of the graph.
Migrations map[string]Migration
// Mapping of all migrations to their parent, if any.
parentage map[string]*Migration
}
func NewMigrationGraph() MigrationGraph {
return MigrationGraph{Migrations: map[string]Migration{}, parentage: map[string]*Migration{}}
}

View file

@ -11,15 +11,6 @@ type Migration struct {
Run bool
}
type MigrationGraph struct {
// Reference to the root of the graph.
Root *Migration
// Name to struct mapping of all migrations part of the graph.
Migrations map[string]Migration
// Mapping of all migrations to their parent, if any.
parentage map[string]*Migration
}
type DB interface {
Execute(sql string) error
}