Migrate Schema with Flyway
On this page
You can integrate Flyway into your SingleStore Helios workspace to manage schema changes in your database using the natively integrated SingleStore driver.
Integration with SingleStore is supported in Flyway version 9.
Prerequisites
-
An active SingleStore Helios workspace.
-
Install the Teams Edition of Flyway command-line.
Connect Flyway to SingleStore Helios
To integrate Flyway into your SingleStore Helios workspace, you need to update the connection parameters for your workspace and the Flyway license key in the Flyway configuration file (flyway.
Here's a sample configuration:
flyway.url=jdbc:singlestore://svchost:3306/dbTest
flyway.user=admin
flyway.password=pa55w0rd!
flyway.schemas=dbTest
flyway.licenseKey=<flywaylicenseKey>
Refer to connection string parameters for more information on the supported parameters.
Example
Flyway migrations are defined in .
files located in the /<flyway-installation>/sql/ directory..
files using the migrate
command.
The following example shows how to perform a SQL-based migration using Flyway.
-
Create a
.
file in the /<flyway-installation>/sql/ directory, say V1_sql Create_ table_ example. sql, and add the following SQL statement: CREATE TABLE example (ID INT NOT NULL,Name VARCHAR(100) NOT NULL); -
Run the
migrate
command in the /<flyway-installation> directory to apply the changes:flyway migrateSuccessfully validated 1 migration (execution time 00:00.020s) Creating Schema History table `dbTest`.`flyway_schema_history` ... Current version of schema `dbTest`: << Empty Schema >> Migrating schema `dbTest` to version "1 - Create table example"
The database is now migrated to version 1.
-
Create another
.
file, say V2_sql Add_ column. sql, and add the following SQL statement: ALTER TABLE example ADD COLUMN Trn DATE; -
Run the
migrate
command:flyway migrateSuccessfully validated 2 migrations (execution time 00:00.023s) Current version of schema `dbTest`: 1 Migrating schema `dbTest` to version "2 - Add column" Successfully applied 1 migration to schema `dbTest`, now at version v2
This command validates and runs both the migrations, and the database is now migrated to version 2.
References
Last modified: September 27, 2023