Tutorial - Save development database changes to the schema model
Published 17 January 2025
If you make changes to your development database and refresh the schema model page, these changes should show up. You can click on an object at the top to see how it has changed at the bottom. The left side shows what is currently in the working folder. The right side shows what is in the database, the newer version that will be saved to the Schema model folder.
You can also multi select objects using Shift + Click.
If you select any changes you want to capture, and then click Save to project, each change will be saved as its own CREATE DDL script in the schema-model folder under your project.
If you go to your project folder or click on the link to the Schema model, then you can see how this is stored on disk:
d..
Run the diff command to get the list of differences and generate an artifact
- $ flyway diff -source=development -target=schemaModel
- Flyway Enterprise Edition 11.2.0 by Redgate
- Licensed to red-gate.com (license ID 1174ed6b-b10e-41bd-9a1b-285ddc3239c7)
- See release notes here: https://rd.gt/416ObMi
- diff artifact generated: C:\Users\Flyway\AppData\Local\Temp\flyway.artifact.diff
- +-----------------------------+--------+-----------------------+----------------+---------------------------------------+
- | Id | Change | Object Type | Schema | Name |
- +-----------------------------+--------+-----------------------+----------------+---------------------------------------+
- | YoZgVMdZR3p7FZEygVaRX9MoF2w | Add | DDL trigger | | ddlDatabaseTriggerLog |
- | ZKZljmz2_Vvl5wLmV.mczvanHzM | Add | Extended property | | MS_Description |
- | VYj3ZC0OtkZR4CbJ_JHm9BMkg_c | Add | Full text catalog | | AW2016FullTextCatalog |
- | qlJstpTbyOQ7nRXTfUvY4lnUDIA | Add | Function | dbo | ufnGetAccountingEndDate |
- ...
- | YreyZ8E1z3onEQFgWSGvDqaDUeY | Add | XML schema collection | Production | ProductDescriptionSchemaCollection |
- | UJr0Z.pCcr8O5ntP1w6H9teL8kQ | Add | XML schema collection | Sales | StoreSurveySchemaCollection |
- +-----------------------------+--------+-----------------------+----------------+---------------------------------------+
Running the model
command to update the schema model folder
- $ flyway model
- Flyway Enterprise Edition 11.2.0 by Redgate
- Licensed to red-gate.com (license ID 1174ed6b-b10e-41bd-9a1b-285ddc3239c7)
- See release notes here: https://rd.gt/416ObMi
- Saved to schema model
- File updated: C:\Users\Flyway\FlywayProjects\SqlServerProject\schema-model\Database Triggers\ddlDatabaseTriggerLog.sql
- File updated: C:\Users\Flyway\FlywayProjects\SqlServerProject\schema-model\Extended Properties\MS_Description.sql
- File updated: C:\Users\Flyway\FlywayProjects\SqlServerProject\schema-model\Functions\dbo.ufnGetAccountingEndDate.sql
- ...
- File updated: C:\Users\Flyway\FlywayProjects\SqlServerProject\schema-model\Views\Sales.vStoreWithContacts.sql
- File updated: C:\Users\Flyway\FlywayProjects\SqlServerProject\schema-model\Views\Sales.vStoreWithDemographics.sql
Note that the diff command is generating an artifact to a temporary directory that the model command is then using to perform the update operation. This will not be cleaned up although it will be overwritten the next time the diff command is invoked. You may want to configure an explicit artifact location instead.
This tutorial has implicitly selected all the differences in the update. A subset of changes could instead be selected using the ids that appear in the diff output.
Next steps
Optionally save your new project to Version Control:
Then pick one of the following:
- Continue making changes to your schema model by repeating the process
- If you want to automatically generate migrations, Generate migrations
- Manually deploy your change to a database
- Configure your CI/DC pipeline to validate and deploy your changes whenever you push to Version Control