1. Deployments and vault changes

This guide covers the safe movement of a Connector-based solution between environments (DEV → QA → Production) and what to do when the target vault changes.

1.1. Key scenarios

  • Moving from one environment to another while preserving aliases and IDs.

  • Pointing an existing SQL database at a different vault.

  • Refreshing metadata without losing user-defined columns in class tables.

1.2. New vault (greenfield) deployments

Best practice is to create a new database, install the Connector from the installer package, and then script any custom procedures from the previous database into the new database if required.

Just repointing an existing database to a different vault is possible, but requires careful planning and consideration of all metadata-related tables, views, and custom procedures.

1.3. Environments created as a structure copy of DEV

When QA or Production is created as a structure copy of DEV, all M‑Files object references typically remain the same. In this scenario:

1.3.1. Update settings

Update the values in the settings table to point to the new vault.

1.3.2. Synchronize metadata

Use the procedure spMFDropAndUpdateMetadata to synchronize metadata after the vault was changed in the settings table. This procedure will retain all the user-defined columns in the Connector tables.

1.4. Migrating the vault to M-Files Cloud

When an on-premises vault is replicated to M-Files Cloud, the cloud vault keeps the structure but the object IDs can change: an object that was 514 in the on-premises vault can be 618 in the cloud vault. This case sits between the two above. There are two ways to handle it:

  • Start a fresh database, as for a new vault (see above). This suits a small solution with little custom code.

  • Keep the database and refresh it against the cloud vault. This suits a solution with many integrations and custom procedures. The steps are below.

To keep and refresh the database:

  1. Take a snapshot while no objects are checked out in the vault: a copy-only backup of the Connector database, the class tables with their data, the IncludeInApp values in MFClass, and the metadata IDs, so you can compare afterwards.

  2. Point the database at the cloud vault with spMFsettingsForVaultUpdate: the cloud vault’s host name, protocol 5 (gRPC), endpoint 443 and the cloud vault’s GUID. See its “Cloud vaults” section. Then run spMFVaultConnectionTest.

  3. Mark every class table to reset. The reset in the next step only drops and recreates the class tables of classes whose IncludeInApp is set when it starts. A class table whose class has no IncludeInApp value is not reset, and keeps the old object IDs. Find those tables and set IncludeInApp on their classes first:

    SELECT mc.Name, mc.TableName, mc.IncludeInApp
    FROM dbo.MFClass AS mc
    WHERE ISNULL(mc.IncludeInApp, 0) = 0
      AND mc.TableName IN (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES);
    
  4. Refresh the metadata and reset the class tables:

    EXEC dbo.spMFDropAndUpdateMetadata @WithClassTableReset = 1,
                                       @IsStructureOnly     = 0;
    
  5. Check the result. Confirm that every class table was reset and reloaded, and compare object IDs with the snapshot. Custom procedures that use object IDs or metadata IDs directly must be checked against the new IDs.

If the vault uses the context menu or other VaultApp actions, the cloud vault reaches SQL through the MFSQL Web API; see Cloud: install Web API.

1.5. Scripting and deployment tooling

In larger solutions with many custom procedures and functions, use a scripting tool to manage deployments consistently. The DBDeployTool is available on request to assist with this task.

1.6. Notes and tips

  • Several class tables include custom data. A metadata refresh maintains these user-defined columns; it does not overwrite them.

  • Always validate on QA using a representative dataset before moving to Production.

  • Keep a rollback plan: a recent database backup plus a simple way to restore the previous MFSettings values.