Create once, maintain over time, apply everywhere. DataTongs keeps environments aligned without hand-written scripts.
Now that you have your source and structure under source control and you've got your state based deployments in place it's time to manage your seed data in the same way. DataTongs will help you extract all or parts of your data and manage deployment via generated MERGE scripts using the data in a Json format. It connects to a SQL Server database and extracts data for the tables specified in the config file and will generate MERGE statements that insert missing rows and optionally update and delete based on the extracted data as well. You can define a filter clause in case you allow mixing user and system data in a single table and both the extraction and DELETE will honor that filter.
Simply point the application at a database with the correct seed data to capture, fill out the list of tables and the key columns for each, set the merge options you wish to generate and we'll handle generating the scripts for you. You can generate new scripts any time you need to update the seed data or manually update the script(s) if you find that simpler. Your application seed data will become part of your source control and state based updates.
appSettings.json
| Setting | Value |
|---|---|
Source:Server | The server to connect and extract from. |
Source:User | The user to authenticate with. Leave blank to use Windows authentication. |
Source:Password | The password to authenticate with. Leave blank to use Windows authentication. |
Source:Database | The database to extract from. |
OutputPath | The path to write the generated scripts. |
Tables | Key value pairs of schema.table and the list of columns to match. Normally the PK or another unique index. |
TableFilters | Key value pairs of schema.table and the optional filter clause for selecting and/or deleting data. |
ShouldCast:MergeUpdate | Indicates whether the generated MERGE statement should update modified values. Defaults to true. |
ShouldCast:MergeDelete | Indicates whether the generated MERGE statement should delete rows not provided. Defaults to true. |
Execute DataTongs from the command line and tongs will begin the casting process.
> DataTongs
Test the scripts and then include them in the TableData folder under your template to make them part of your state based deployment process.
See the DataTongs Walkthrough to help you get started with the tool.
The export will be a series of scripts containing the table contents in json form and a MERGE statement generated to insert missing rows. Optionally an update and/or delete section will be included in the MERGE depending on your configuration. We have a special folder in the template definition intended to deploy these script. It supports looping to assist with dependency management though it is certainly faster if you modify script names to order the deployment to account for those. The scripts in the TableData folder under your template will be executed every release and will perform the looping as needed before reporting any scripts that can't be deployed successfully.
You can also use this tool to script out test data as well and then use the scripts outside of SchemaQuench to deploy test data as needed via your test pipeline. This can simplify the setup of integration test data and allow you to easily reset to a consistent starting state between test runs.