flyway-dev command line
Published 24 October 2022
The flyway-dev CLI is an internal component that performs some of the tasks that are surfaced in Flyway Desktop. It is currently available as Preview Software for users to trial and provide feedback. The command syntax is likely to change in 2024 when we hope to release a fully supported command line with similar capabilities. Learn more about Preview Software.
Note: If you are using this command line, we would like to understand why. Please email the developers with what you are trying to do and how your experience has been. We appreciate your feedback.
The flyway-dev command line is installed as part of Flyway Desktop. For the latest information, run:
flyway-dev --help
As of October 2022:
Commands | |
---|---|
init | Create a new project directory in a given location. |
diff | Calculate the differences between two targets (for example, migrations and the schema model). |
show | Show and optionally filter changes from a diff artifact. |
take | Choose ids from a diff artifact to use with 'flyway-dev apply' or 'flyway-dev generate'. |
apply | Apply selected changes from a diff artifact to the target. |
generate | Generate preview migrations from a diff artifact. |
promote | Promotes the preview migrations from 'flyway-dev generate' into the flyway migrations directory. |
resolve | Resolves a database using supplied connection information. |
project-load | Read the project configuration to standard out. |
import-project | Create a new project in a directory containing a flyway config file. |
next-migration-name | Generates next versioned migration name and corresponding undo migration name. |
parse-migration-name | Parses migration name into constituent parts. |
construct-migration-name | Constructs migration name from constituent parts. |
Run help on each command above for more details about it's usage.
flyway-dev [command] --help
Options | |
---|---|
--version | Show version information |
-?, -h, --help | Show help and usage information |
-q, --quiet | Specifies quiet logging |
-v, --verbose | Specifies verbose logging |
--format, --output <Json|Text> | Specifies the output format [default: Text] |
--i-agree-to-the-eula (REQUIRED) | By using this option you consent to the Redgate EULA found at https://www.red-gate.com/eula |
Project file formats
- JSON project files are pathed to by directory
- TOML project files are pathed explicitly. E.G --project 'C:\WorkingFolders\FWD\ProjectFolder\flyway.TOML'
Examples:
Example One: Creating a new project and saving database changes to the schema model on disk
Create a new project giving it a name and path:
flyway-dev init --name=TestFdCmdLine --path=C:\Users\redgate\Documents\TestFdCmdLine --database-type=SqlServer --i-agree-to-the-eula
If the folder doesn't exist, it will be created.
Update the development database in the user (-u=true) or project settings (-u=false; this is the default)
See the differences between your Development Database and your Schema Model on disk and save this into an artifact (in temp folder) for later use:
flyway-dev diff -p=C:\Users\redgate\Documents\TestFdCmdLine --from=Dev --to=SchemaModel -a=C:\Users\redgate\Documents\TestFdCmdLine\Temp\artifact1 --i-agree-to-the-eula
In this example, there's only one table in the database. Since this is a new project, this appears as the only difference:
The schema-model folder is still empty:
You can see the differences in the artifact using the show command:
flyway-dev show -p=C:\Users\redgate\Documents\TestFdCmdLine -a=C:\Users\redgate\Documents\TestFdCmdLine\Temp\artifact1 --i-agree-to-the-eula
Apply the differences to the schema-model folder using the artifact in the previous step:
flyway-dev apply -p=C:\Users\redgate\Documents\TestFdCmdLine -a=C:\Users\redgate\Documents\TestFdCmdLine\Temp\artifact1 -c=VGFibGU6W2Rib10uW1Rlc3RUYWJsZV0 --i-agree-to-the-eula
The schema model on disk is now updated:
Next steps:
Continue to use flyway-dev [command] --help to continue working with the command line.
- Use project-update to setup your shadow database.
- Use diff with --from=SchemaModel --to=Migrations to see the database changes on disk that have not been included in a migration script yet.
- Use generate to take the differences in the artifact created in the previous step and generate the next versioned migration script.
- Use promote to save the migrations to the project.
Example Two: Get the version information for the next migration script
- If a project has been created, use next-migration-name with the path to the project and a description to get the next filename you should use for your migration scripts.
Example Three: Initialize a new project and generate a baseline script
# Create a project (Oracle) flyway-dev init -n ProjectName -p C:\WorkingFolders\FWD\ProjectFolder --database-type Oracle --i-agree-to-the-eula # Get the differences from Production like DB $diffs = echo '{ "url": "jdbc:oracle:thin:@//localhost:1521/Production", "user": "OracleUser", "password": "OraclePassword", "token": null, "schemas": ["SchemaName"], "resolverProperties": [] }' | flyway-dev diff -p 'C:\WorkingFolders\FWD\ProjectFolder' -a 'C:\WorkingFolders\FWD\ProjectFolder\artifact.zip' --from Target --to Empty --output json --i-agree-to-the-eula | ConvertFrom-Json # Generate the baseline from all differences echo $diffs.differences.id | flyway-dev generate -p 'C:\WorkingFolders\FWD\ProjectFolder' -a 'C:\WorkingFolders\FWD\ProjectFolder\artifact.zip' -o 'C:\WorkingFolders\FWD\ProjectFolder\migrations' --name 'B1__BaselineScript.sql' --versioned-only --i-agree-to-the-eula
Feedback
If you are using this command line, we would like to understand why. Please email the developers with what you are trying to do and how your experience has been. We appreciate your feedback.