Skip to content

provider.ApplyVersion does not respect the disable-versioning config #934

Open
@markvai

Description

@markvai

Hi,

I saw the great addition of no versioning and wanted to use that to add testing to our migrations.

However, I would like to test each migration separately and for that I would like to seed the DB for that migration, with one specific migration file, not all files with lower version.

To do that, it seems that there is support for applying a single version with the provider method ApplyVersion but that method doesn't seem to check the disableVersioning field and query the DB for existing versions.

My planned test is something like that:

p, err := NewProvider(...)
pNoVersions, err := NewProvider(..., goose.WithDisableVersioning)

// Collect and sort the migrations
for _. m := range sortedMigrations {
  // This is where I want to run only a specific seed file
  pNoVersions.ApplyVersion(m.Version, true)

  p.ApplyVersion(m.Version, true)

  // Revert the seed so the next test is isolated from previous ones
  pNoVersions.ApplyVersion(m.Version, false)
}

However, I get errors:

  1. An error since the goose_db_version doesn't exist on the first call to ApplyVersion
  2. An error if I want to run a down migration before I revert the seed data, this is because no applied version is found, but this should be fine since I am using a provider with the config disableVersioning

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions