Development

Journey Command CLI

The most versatile use of Journey is through the Journey Command application that shines the most during development rather than in production. Invocations of the application have the following structure:

journey [Command] [Option|Flag(s)] [OptionValue]

See Command Reference and Option Reference for more details on all commands and options.

Scaffolding
journey scaffold -p "path\to\versions-dir" -d sqlite -c "Data Source=journal.db"

To get things rolling, the first step is to obtain a scaffoding of the next version’s migration file. This is done by running the Scaffold command, which will provide a starting point for adding queries that will transition the database to the next version.

Validation
journey validate -p "path\to\versions-dir" -d sqlite -c "Data Source=journal.db"

After adding the queries that should change the database, the next step would be to run Validate command, which ensure that the file conforms to expectations of the Journey migration tool. This reduces the risk of database corruption because of syntax errors in the migration script. Of course, if the queries themselves are harmful but syntatically correct, this command wont be of much help. This command will validate the latest version in the versions directory.

Migrating
journey migrate -p "path\to\versions-dir" -d sqlite -c "Data Source=journal.db"

Once the migration file is prepared, its time to apply it by running the Migrate command. This will execute the queries contained in the migration section of the file against the database. This command will migrate the latest version in the versions directory.

Rollback
journey rolback -p "path\to\versions-dir" -d sqlite -c "Data Source=journal.db"

In the event the changes were not ideal or what was expected, the database can be restored back to the state it was in before the migration by running the Rollback command. This executes the queries contained in the rollback section of the migration file against the database which, if prepared correctly should completely reverse the effects of the migration queries without any side effects. This command will rollback the latest version in the versions directory.

Update
journey update -p "path\to\versions-dir" -d sqlite -c "Data Source=journal.db"

To sync the database to the highest version in the versions directory, you can run the Update command. This is the most common use case in a non-development environment such as when using the .Net library version of Journey.

History
journey history -p "path\to\versions-dir" -d sqlite -c "Data Source=journal.db"

To get a description of the migrations that have been applied to the database up to the current version, you would run the History command which returns the descriptions, authors an run time of all migrations that have been run against the database up to the latest version. This command will return the descriptions of the 10 latest migrations.