From 455054add2c7aed0a3a46d1e0c0b4ef43d0ba7bb Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Thu, 11 Jul 2024 21:16:44 -0400 Subject: [PATCH] refactor: ApplyMigration > Apply, remove naming redundancy --- cobble.go | 2 +- migrate_test.go | 6 +++--- migration.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cobble.go b/cobble.go index 7076ef0..84972ab 100644 --- a/cobble.go +++ b/cobble.go @@ -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) } } diff --git a/migrate_test.go b/migrate_test.go index 78c740b..15ba267 100644 --- a/migrate_test.go +++ b/migrate_test.go @@ -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") diff --git a/migration.go b/migration.go index 4be086f..58213a6 100644 --- a/migration.go +++ b/migration.go @@ -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 {