You can move data from an application running with XML persistence into an application running with MDrivenServer persistence by exporting a migration file and then importing that file into the target persistence.
What this procedure moves
This procedure uses the Migrate tool to transfer the objects and relations currently stored in an XML persistence file to MDrivenServer persistence.
The migration file is an intermediate file. You create it while the application runs against the XML source, then read it while the application runs against the MDrivenServer target.
For example, if your XML-backed application contains 24 objects and 22 relations, the import confirmation can report that it created 24 objects and set 22 relations in the target persistence.
| Stage | Persistence in use | Migrate action | Result |
|---|---|---|---|
| Export | XML file | Read the source data and write a migration file | A file such as migrateToDB.xml contains the data to transfer.
|
| Import | MDrivenServer | Read the migration file and save its contents | The objects and relations are written to MDrivenServer persistence. |
Before you start
- Ensure that you can start the application with its existing XML persistence and that the source data is present.
- Ensure that MDrivenServer persistence is configured and available as the target. For database connection and production setup guidance, see Documentation:Configuring Production Databases PostgreSQL MySQL MSSQL.
- Choose a location and name for the migration file, for example
migrateToDB.xml. Keep the file available until the import has completed and you have verified the target data. - Treat the XML source data as the source of record until you have verified the imported data.
Export data from XML persistence
- Start the system using XML persistence.
- Select Migrate.
- In the Migrate dialog, select the green action button. This loads the data from the XML persistence and writes it to a migration file.
- When prompted for a file location, save the migration file. For example, save it as
migrateToDB.xml. - Wait for the export to finish, then close the Migrate dialog.
At this point, the migration file contains the data read from the XML source. It has not yet been written to MDrivenServer persistence.
Import data into MDrivenServer persistence
- Change the application's persistence setting to MDrivenServer persistence.
- Start the system against MDrivenServer persistence.
- Select Migrate.
- In the Migrate dialog, select the pink action button to read a migration file.
- Choose the file created during export, for example
migrateToDB.xml. - Review the completion message. It reports how many objects were created and how many relations were set.
- Select the yellow action button to save the imported changes to MDrivenServer persistence.
Verify the migration
After saving, check that the expected data is available when the system runs against MDrivenServer persistence.
- Confirm that expected objects are present. For example, compare the number of imported objects reported by Migrate with the data you expect from the XML source.
- Confirm that related data is connected. The completion message reports relations separately, so an object count alone does not confirm that relations were restored.
- Keep the XML source and migration file until you have completed this verification.
Scope and alternatives
This workflow transfers data through a migration file from XML persistence to MDrivenServer persistence. It is not a procedure for importing an existing third-party SQL database or for reverse-engineering its schema.
- To import data from another SQL Server, use HowTos:Import Data from Other SQL Servers.
- To create a model from an existing database schema, use HowTos:Reverse Engineer a Database.
- For background on available persistence mechanisms, see Documentation:Persistence mappers.
- To import tabular data through OCL operators, see HowTos:Import Tabular Separated Data Using OCLOperators.
Walkthrough
Watch the migration walkthrough for a demonstration of exporting XML data to a migration file and importing it into MDrivenServer persistence.
See also
- Documentation:Configuring Production Databases PostgreSQL MySQL MSSQL
- Documentation:Persistence mappers
- HowTos:Import Data from Other SQL Servers
- HowTos:Reverse Engineer a Database
- HowTos:HowTo
Data migration workflow
Data migration workflow
The Migrate tool can move data between persistence options. The video describes using it when data must be moved between XML files, local or cloud databases, or other configured persistence targets.
The workflow is intended for moving a manageable amount of data. It is not intended for millions of objects. When working with a larger database, the tool can use a cap value to export a subset of the data.
Before you begin
- Back up application and user data before starting a migration.
- Start the system against the source persistence before exporting data.
- Choose the target persistence before importing the migration file.
- Do not import a migration file back into the source store unless duplicate objects are intended. The video states that imported objects are treated as new.
Export data
- Start the system against the source persistence.
- Open Migrate.
- Export the data to a migration file. The demonstrated migration file is an XML file.
- Save the migration file in a location available to the target environment.
During export, the tool processes classes and their associations. The video also states that delayed-fetched attributes are fetched efficiently during this process.
Import data into a different persistence target
- Close or stop the session that is running against the source persistence.
- Configure and start the system against the target persistence.
- Open Migrate.
- Read the migration XML file into the current target persistence.
- Save the imported data to the target persistence.
- Verify the imported data in the application or debugger.
The video demonstrates this general approach for XML persistence and for database targets. It also demonstrates creating schemas for SQLite and SQL Server Compact before loading a data dump into those targets.
Scope
This workflow concerns moving data between persistence stores. The supplied sources do not document a general procedure for handling database schema changes after model changes. Use the applicable product documentation or obtain support before treating a data-dump import as a schema-evolution procedure.
For a product walkthrough, see MDriven | Data migration.
