Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specific migrations to be inactivated by name #4

Closed
d-ryan-ashcraft opened this issue Nov 16, 2023 · 2 comments
Closed

Allow specific migrations to be inactivated by name #4

d-ryan-ashcraft opened this issue Nov 16, 2023 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@d-ryan-ashcraft
Copy link
Contributor

d-ryan-ashcraft commented Nov 16, 2023

Automatic migrations are useful in concept, at times it may be desirable for a project or specific module to disable one or more migrations. This could be for a number of reasons, such as an undesirable outcome, overlap with another migration, etc.

To support this concept, it would be nice to provide a list of migration names that will be made inactive to the plugin configuration. This level of granularity supports turning migrations off in a parent module that will impact many Maven modules, at an individual module, or both.

Notional solution that would deactivate any migration named foo or bar in the classpath. If the names are not found, there is no impact.

            <plugin>
                <groupId>org.technologybrewery.baton</groupId>
                <artifactId>baton-maven-plugin</artifactId>
                <configuration>
                    <deactivateMigrations>
                        <deactivateMigration>foo</deactivateMigration>
                        <deactivateMigration>bar</deactivateMigration>
                    </deactivateMigrations>
                </configuration>
            </plugin>
@d-ryan-ashcraft
Copy link
Contributor Author

d-ryan-ashcraft commented Nov 17, 2023

Test Steps

  • Check out baton project at https://github.com/TechnologyBrewery/baton
  • Run mvn clean install -Pbootstrap
    • Verify that all unit tests passed successfully (newly added BDD test are included, so this validated functionality in an automated fashion)
  • Run mvn clean install
    • Verify the build completed successfully
    • Validate that module simple-migration-example includes the following output:
      • 2 migrations ran
      • test-migration-b ran once unsuccessfully on a java file
      • test-migration-a ran one successfully on a txt file
      [INFO] --- baton:0.2.0-SNAPSHOT:baton-migrate (default) @ simple-migration-example ---
      [INFO] Loading migrations from: jar:file:/baton/examples/example-migration-configuration/target/example-migration-configuration-0.2.0-SNAPSHOT.jar!/migrations.json
      [INFO] Found 2 migrations
      [INFO] Performing unsuccessful migration `test-migration-b` on file `/baton/examples/example-projects/simple-migration-example/src/main/java/org/technologybrewery/baton/test/JavaFileToBeMigrated.java`
      [INFO] Performing successful migration `test-migration-a` on file `/baton/examples/example-projects/simple-migration-example/src/main/resources/migrate-me.txt`
      [INFO] Migrations Processed: 2, Successfully Migrated Files: 1, Unsuccessfully Migrated Files: 1
      
    • Open baton/example-projects/ignore-migration-example/pom.xml and note that migration-b is deactivated
    • Validate that module ignore-migration-example includes the following output:
      • 1 migrations ran
      • test-migration-b was inactivated
      • test-migration-a ran one successfully on a txt file
      [INFO] --- baton:0.2.0-SNAPSHOT:baton-migrate (default) @ ignore-migration-example ---
      [INFO] Loading migrations from: jar:file:/baton/examples/example-migration-configuration/target/example-migration-configuration-0.2.0-SNAPSHOT.jar!/migrations.json
      [INFO] Found 2 migrations
      [INFO] Skipping deactivated migration: test-migration-b
      [INFO] Performing successful migration `test-migration-a` on file `/baton/examples/example-projects/ignore-migration-example/src/main/resources/migrate-me.txt`
      [INFO] Migrations Processed: 1, Successfully Migrated Files: 1, Unsuccessfully Migrated Files: 0
      

d-ryan-ashcraft added a commit that referenced this issue Nov 17, 2023
…ption

#4 ✨ support deactivating a migration by name; improve examp…
@d-ryan-ashcraft
Copy link
Contributor Author

CI build passed:
image

@d-ryan-ashcraft d-ryan-ashcraft removed their assignment Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant