refactor: ApplyMigration > Apply, remove naming redundancy
All checks were successful
/ sast (push) Successful in 45s
/ tests (push) Successful in 48s

This commit is contained in:
Marc 2024-07-11 21:16:44 -04:00
parent 0dc457ec9c
commit 455054add2
Signed by: marc
GPG key ID: 048E042F22B5DC79
3 changed files with 5 additions and 5 deletions

View file

@ -39,7 +39,7 @@ var up = &cobra.Command{
migrationHistory, _ := migrationGraph.GetLinearHistory()
for _, migration := range migrationHistory {
log.Printf("%s", migration.Name)
if err := migration.ApplyMigration(db); err != nil {
if err := migration.Apply(db); err != nil {
os.Exit(1)
}
}

View file

@ -168,7 +168,7 @@ func TestMigrateRunsSqlOnDBConnection(t *testing.T) {
migrationGraph, _ := NewMigrationGraphFromDirectory(root)
migrations, err := migrationGraph.GetLinearHistory()
err = migrations[0].ApplyMigration(mockDb)
err = migrations[0].Apply(mockDb)
if err != nil {
t.Errorf("Expected no error returned, got %#v", err)
@ -186,7 +186,7 @@ func TestMigrateReturnsErrorOnFailToReadMigrationFile(t *testing.T) {
migrationPath := filepath.Join(root, "0001.sql")
migration := NewMigration(migrationPath, "0001.sql", "")
err := migration.ApplyMigration(mockDb)
err := migration.Apply(mockDb)
if err == nil {
t.Errorf("Expected error returned, got nil")
@ -203,7 +203,7 @@ func TestMigrateReturnsErrorOnFailToRunSQL(t *testing.T) {
migrationGraph, _ := NewMigrationGraphFromDirectory(root)
migrations, err := migrationGraph.GetLinearHistory()
err = migrations[0].ApplyMigration(mockDb)
err = migrations[0].Apply(mockDb)
if err == nil {
t.Errorf("Expected error returned, got nil")

View file

@ -47,7 +47,7 @@ func (m *Migration) Sql() (string, error) {
//
// If an error is returned while trying to read the migration file
// or execute the SQL it contains, the error is returned.
func (m *Migration) ApplyMigration(db DB) error {
func (m *Migration) Apply(db DB) error {
migrationSql, err := m.Sql()
if err != nil {