Redgate Flyway

For PostgreSQL users - where are your DBs hosted?

Tutorial - Use placeholders to allow for conditional data insertion

  1. Learn about adding a new versioned migration script to the project folder.  Create a new Versioned migration script with placeholders and save it to your project.
    Example:

    1. # If your target databases have different names, you can use the default flyway:database placeholder
    2. IF (${flyway:database} == "HR_DEV")
    3. INSERT INTO TBL_ENVIRONMENT VALUES ("DEV");
    4. ELSE IF (${flyway:database} == "HR_TEST")
    5. INSERT INTO TBL_ENVIRONMENT VALUES ("TEST");
    6. ELSE IF (${flyway:database} == "HR_STAGE" || ${flyway:database} == "HR_PROD" )
    7. INSERT INTO TBL_ENVIRONMENT VALUES ("PROD");
    8. END IF
    9.  

    Learn more about placeholders.

  2. When this versioned migration script is deployed to a target environment, it will replace the placeholder with it's corresponding value and run the correct insert statement.


Didn't find what you were looking for?