Migrate from the legacy Snowflake data share target¶
Data shares linked to a legacy Snowflake data share target must be migrated to the Snowflake V2 data share target. Snowflake and Salesforce don’t migrate existing data shares automatically — you need to complete the steps in this topic.
This migration is available in all Salesforce Data 360 editions.
Required permission in Salesforce: Data Cloud Architect permission set.
Prepare the Zero-Copy connector¶
A Snowflake V2 data share target connects to a Zero-Copy connector in your Snowflake account.
If your Salesforce administrator starts the migration from Salesforce, Snowflake can create the connector for you. In that case the following objects appear in your account:
- A database named
CONNECTORS, if it doesn’t already exist, owned byACCOUNTADMIN. - A schema named
CONNECTORS.ZEROCOPY, if it doesn’t already exist. - A connector named
CONNECTORS.ZEROCOPY.SALESFORCE_DATA_CLOUD_<tenant_id>, where<tenant_id>is the Salesforce tenant ID in uppercase with every character other than letters, digits, and underscores replaced by an underscore. The connector is reserved for that Salesforce tenant.
Use that connector rather than creating a second one for the same org. Snowflake doesn’t create a catalog-linked database or swap any database for you.
Otherwise, create a connector and give its Enrollment ID to your Salesforce administrator. See Set up the Salesforce Data Cloud Zero-Copy connector.
Link the data share to the Snowflake V2 data share target¶
- In Salesforce, go to Data 360 » Data Shares.
- Select a data share that’s linked to a legacy Snowflake data share target.
- Link the data share to a Snowflake V2 data share target. See Link the Data Share to the Data Share Target for the linking steps.
Don’t unlink the data share from the legacy target yet.
Verify the Snowflake V2 connection¶
Confirm that data is flowing to Snowflake through the new Zero-Copy connector before you touch the legacy target:
-
Confirm that the connector is in the
CONNECTEDstate with DESCRIBE ZEROCOPY CONNECTOR. -
Create a catalog-linked database from the connector with CREATE DATABASE … LINKED_ZEROCOPY_CONNECTOR. To keep three-part names that reference the legacy
schema_<share_name>schemas working after the swap, setLEGACY_SALESFORCE_SCHEMA_ALIAS = TRUE:For the other options, see Explore data products from Salesforce Data Cloud.
-
Use SYSTEM$ZEROCOPY_CONNECTOR_LIST_SHARES to confirm the data share appears and its status is
MOUNTEDorUNMOUNTEDas expected. See List shared data products. -
Query the catalog-linked database to confirm the shared data looks correct.
Important
Don’t unlink the data share from the legacy target before confirming the Snowflake V2 link is working. Downstream processes in Snowflake may still reference the database created from the legacy target.
Swap to the Snowflake V2 database¶
Existing pipelines and dashboards reference the database created from the legacy target by name. Rather than update every downstream reference, swap the V2 catalog-linked database into that name. The swap is atomic and completes in under a minute.
Choose one of the following options.
Option 1: Using a Cortex Code skill¶
If you have Cortex Code, install the swap-databases skill from
Snowflake-Labs/coco-skills,
either with the command below or through the Snowflake UI:
When prompted, choose MODE C to complete the migration.
The skill:
- Compares the legacy and V2 database structures and validates that the required V2 objects are present.
- Performs an atomic database-name swap so downstream references continue to resolve to the original production database name.
Confirm the schema names match between the two databases when the skill asks you to confirm.
If the names don’t match because the catalog-linked database doesn’t expose the legacy
schema_<share_name> schemas, turn them on without recreating the database by using
ALTER DATABASE … UPDATE LINKED_ZEROCOPY_CONNECTOR:
The schema_<share_name> schemas appear shortly after the statement. They contain the full-named views
only, such as Case_Home__dll, not the short-named views.
Note
If you’re merging multiple data shares into a single catalog-linked database, tell the skill to proceed even if the schema names don’t match.
Option 2: Using a SQL function¶
If you don’t have Cortex Code, validate the databases and schemas yourself before and after the swap, then run SYSTEM$ZEROCOPY_SWAP_IMPORTED_DB_WITH_CLD:
<imported_db_name>: the database created from the legacy target. It must be a database created from a share.<cld_db_name>: the catalog-linked database created from the Salesforce Zero-Copy connector (V2).
The role that runs the function must own both databases. The function fails if the first argument isn’t a database created from a share or the second isn’t a catalog-linked database created from a Salesforce Zero-Copy connector. It only exchanges the two database names. It doesn’t check that the connector is connected or that the schemas match; validate those yourself first.
Grant access to the catalog-linked database¶
Grants stay with the database they were made on, not with its name. After the swap, roles that queried the legacy database still have their privileges on the legacy database, which now has the catalog-linked database’s old name. They have no privileges on the catalog-linked database that now has the production name.
Before or right after the swap, grant the same roles access to the catalog-linked database:
-
Find the roles that use the legacy database:
-
Grant each of those roles access to the catalog-linked database. If you set
LEGACY_SALESFORCE_SCHEMA_ALIAS = TRUE, wait until theschema_<share_name>schemas appear so that the grants include them:
Use whichever database name is current when you run the statements. For more information, see Explore data products from Salesforce Data Cloud.
Roll back the swap¶
To undo the swap, call the function again with the arguments in the reverse order. The first argument must always be the database created from the share, which carries the catalog-linked database’s original name after the swap:
Unlink the data share from the legacy target¶
Once the swap is validated:
- On the data share’s record home page, click Link/Unlink Data Share Target.
- Deselect the legacy data share target.
- Click Save.