From a8c9167e24a001d1a48f212197645fb8de1cbb03 Mon Sep 17 00:00:00 2001 From: Asaf Gartner Date: Mon, 12 Apr 2021 16:51:30 +0300 Subject: [PATCH] Removed irrelevant code. --- src/migration/migration.go | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/migration/migration.go b/src/migration/migration.go index 5f454cbb..d2470819 100644 --- a/src/migration/migration.go +++ b/src/migration/migration.go @@ -283,34 +283,6 @@ func MakeMigration(name, description string) { fmt.Println(path) } -// Drops all tables -func ClearDatabase() { - conn := db.NewConn() - defer conn.Close(context.Background()) - - dbName := config.Config.Postgres.DbName - rows, err := conn.Query(context.Background(), "SELECT tablename FROM pg_tables WHERE tableowner = $1", dbName) - if err != nil { - panic(fmt.Errorf("couldn't fetch the list of tables owned by %s: %w", dbName, err)) - } - - tablesToDrop := []string{} - - for rows.Next() { - var tableName string - err = rows.Scan(&tableName) - if err != nil { - panic(fmt.Errorf("failed to fetch row from pg_tables: %w", err)) - } - tablesToDrop = append(tablesToDrop, tableName) - } - rows.Close() - - for _, tableName := range tablesToDrop { - conn.Exec(context.Background(), "DROP TABLE $1", tableName) - } -} - // Applies a cloned db to the local db. // Drops the db and runs migrations from scratch. // Applies the seed after the migration specified in `afterMigration`, then runs the rest of the migrations. @@ -327,9 +299,6 @@ func SeedFromFile(seedFile string, afterMigration types.MigrationVersion) { panic(fmt.Errorf("could not find migration: %s", afterMigration)) } - fmt.Println("Clearing database...") - ClearDatabase() - fmt.Println("Running migrations...") Migrate(afterMigration)