Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Fix checking for auto-reset on apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Kate Döen committed Aug 31, 2022
1 parent 45d4b89 commit 4058c1f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ func NewApplyCommand() *cobra.Command {
}
}

schemaMigrationsTableExists, err := internal.CheckTableExists(ctx, conn, "public", "schema_migrations")
if err != nil {
return fmt.Errorf("failed to check if public.schema_migrations exists: %w", err)
}

if schemaMigrationsTableExists != databaseExists {
//nolint:lll,goerr113
return fmt.Errorf("something is wrong, the database and the schema_migrations table should always exist or not exist together")
}

for _, u := range config.DatabaseUsers {
var userExists bool
userExists, err = internal.CheckUserExists(ctx, conn, u)
Expand Down Expand Up @@ -142,7 +132,7 @@ func NewApplyCommand() *cobra.Command {
return fmt.Errorf("failed to initialize go-migrate: %w", err)
}

if resetDatabase || (!databaseExists && !schemaMigrationsTableExists) {
if resetDatabase || !databaseExists {
var files []os.DirEntry
files, err = os.ReadDir(migrationsDir)
if err != nil {
Expand Down

0 comments on commit 4058c1f

Please sign in to comment.