Table of Contents
Source Control HELP
The Source Control feature of Valentina Studio Pro provides an ability of database development using any VCS. Using Source control you can easily:
- Commit the initial schema version - make snapshot of the current database schema.
- Evaluate and Commit changes in the database schema.
- Migrate to the particular schema version.
To start using Source Control you should select the target database in the Schema Editor, and go to the Main Menu → Tools → Source Control.
- Path – the path to the Source Control folder. The place where all scripts and support files will be placed.
- Content Type – the approach (tool) that will be used for making schema snapshots.
- Register/Unregister Database – the button to bind the Source Control to the particular database.
Dependently on content of Source Control Folder there are two possible workflows:
- Commit Initial Version – if folder is empty you should to create initial commit with the current schema version of the database.
- Migrate to Version – if the selected folder already contains Source Control files you should migrate the database schema to the current state in the Source Control Folder.
Commit Schema Version
One of the goal of Source Control is to track schema changes. You can do this by Commit changes in the schema to the appropriate snapshots (SQLDump or Script Folder):
- Current Schema State – the snapshot of the current database schema version.
- Previous Schema State – the snapshot of the previous schema version.
- Migration Script – the script to migrate the previous schema state to the current.
- Rollback Script – the script to rollback migration changes.
All of this items can be obtained and managed by the Source Control.
Committing the schema version is sophisticated process that can include many steps. Commit can be performed only when all steps are ready. If the step is not ready you should perform additional operations to prepare the particular step. Each step contains description that will help you to perform preparation actions. When the scenario will be applied all steps will be marked as finished.
When the database just registered in the Source Control you should create the Initial Commit. This step will create snapshot of the current database schema and Source Control files.
- Path to Sources – the path to the Source Control Folder on the local disk.
- Schema Version – the local version of database schema.
- Sources Version – the current version of schema in the Source Control Folder.
- Commit Scenario – describes steps that will be performed to create initial version.
- Commit – execute the commit scenario create scema version
Increase Schema Version
When database was changed you can create a new schema version in the Source Control. Firstly to determine schema changes you should to compare the current schema with initial. To perform this task you need to select database with source schema version:
- SQLDiff Panel – on this panel you should select source database. You can use Connect To button to open remote connection or local database.
- Run SQLDiff – performs comparison.
- Commit Scenario – shows the stage of commit scenario. Currently the scenario can't be performed because synchronization and rollback scripts are not ready. To prepare these scripts need to run SQLDiff - it will determine difference between database schemas and create scripts.
- Commit – creates schema version in the Source Control.
When SQLDiff compared databases you can see the list of differences in schemas. Now you can see that all steps in the commit scenario is ready to run.
When commit scenario is performed - you can see that all steps are marked as finished. Now the Source Control Folder will be looked like this:
- current_sql_dump.sql – SQL Dump of the current schema version.
- previous_sql_dump.sql – SQL Dump of the previous schema version.
- current_script_folder – Script Folder of the current schema version.
- previous_script_folder – Script Folder of the previous schema version.
- rollback.sql – the script to migrate from previous schema version to current.
- synchronization.sql* – the script to rollback the current migration.
- vs_source_control – internal data for the Source Control
Migrate Schema Version
Automation of migration schema version is another function of Source Control. There are two ways to perform migration to a particular version:
- Create the schema according to the current version in the source control. This step should be performed when the current database is empty.
- Migrate to the new version. This step should be performed when the current Schema Version is lesser than schema version in the Source Control Folder.
If you want to create database with particular schema version you should to create a new database in the Schema Editor and register one in the Source Control with existing Source Control Folder.
- Migration Script – shows the script for changing the schema. For the initial migration is a SQLDump for the current schema sate.
- Migrate – applies the migration script.
- Migration Script – shows the script for changing the schema. This is a synchronization script generated by the SQLDiff.
- Migrate – applies the migration script.