You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migration-tools/Cortex_Code_Skill/dcm-migrate/SKILL.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,7 @@ Scans a database, retrieves DDL for all objects (tables, views, dynamic tables,
49
49
50
50
Automatically skips (reported as UNSUPPORTED):
51
51
-**Semantic views** (not yet supported by DCM)
52
+
-**Data metric functions** (GET_DDL signature does not match regular functions)
52
53
-**Non-SQL functions and procedures** (Python, Java, JavaScript, Scala)
53
54
-**External stages** (have a URL — manage outside DCM)
54
55
-**OWNERSHIP grants** (implicit from object creation)
@@ -64,18 +65,20 @@ When an unsupported row appears in the output, the reason is given in the `file_
64
65
```bash
65
66
SNOWFLAKE_CONNECTION_NAME=<connection> uv run --project <SKILL_DIR> \
66
67
python <SKILL_DIR>/scripts/ddl_to_dcm.py \
67
-
--database <DB_NAME> \
68
-
--output <PROJECT_DIR>/sources/definitions \
69
-
[--schemas SCHEMA1 SCHEMA2 ...] \
70
-
[--group-by-type] \
68
+
--db-name <DB_NAME> \
69
+
[--schema-list SCHEMA1 SCHEMA2 ...] \
70
+
[--object-types TYPE1 TYPE2 ...] \
71
+
[--group-files-by-type] \
72
+
--output-path <PROJECT_DIR>/sources/definitions \
71
73
[--role <ROLE_NAME>]
72
74
```
73
75
74
76
**Arguments:**
75
-
-`--database` (required): Source database name
76
-
-`--output` (required): Local directory for generated definition files
77
-
-`--schemas` (optional): Space-separated schema allow-list; omit for all schemas
78
-
-`--group-by-type` (optional): Write one file per object type per schema (recommended for large databases)
77
+
-`--db-name` (required): Source database name
78
+
-`--schema-list` (optional): Space-separated schema allow-list; omit for all schemas
79
+
-`--object-types` (optional): Space-separated object-type allow-list. Accepted values (case-insensitive, spaces or underscores): `TABLE`, `VIEW`, `DYNAMIC TABLE`, `TASK`, `FUNCTION`, `PROCEDURE`, `SEQUENCE`, `FILE FORMAT`, `ALERT`, `TAG`, `STAGE`, `SCHEMA`, `GRANT`. Omit for all supported types. Any unknown value aborts the run with an ERROR row before any Snowflake calls are made.
80
+
-`--group-files-by-type` (optional): Write one file per object type per schema (recommended for large databases)
81
+
-`--output-path` (required): Local directory for generated definition files
79
82
-`--connection` (optional): Snowflake connection name override. Normally use the `SNOWFLAKE_CONNECTION_NAME` env var instead.
80
83
-`--role` (optional): Only migrate objects owned by this role. Filters schemas, tables, views, dynamic tables, tasks, functions, procedures, sequences, file formats, alerts, tags, and internal stages by the `owner` column. Recommended for non-ACCOUNTADMIN users to avoid permission errors on unowned objects.
81
84
@@ -155,9 +158,10 @@ Collect from the user:
155
158
156
159
1.**Source database** (required)
157
160
2.**Schema allow-list** (optional; omit for all schemas)
158
-
3.**Target DCM project** — new or existing?
159
-
4.**Connection** — which Snowflake connection to use
160
-
5.**Group by type** — one file per type per schema (recommended) or one file per object
5.**Connection** — which Snowflake connection to use
164
+
6.**Group by type** — one file per type per schema (recommended) or one file per object
161
165
162
166
**Path handling:** Files must be on the local filesystem (DCM CLI requires it). If the user specifies a workspace/stage path, explain this and offer to sync after migration via `snow stage copy`.
163
167
@@ -242,13 +246,13 @@ Collect from the user:
242
246
243
247
#### Local mode
244
248
245
-
Run `ddl_to_dcm.py` using the command from the **Tools** section above, with `--output <project_dir>/sources/definitions --group-by-type`. Add `--schemas` if only specific schemas should be migrated. If the user chose **owned-only** in Step 1, add `--role <ROLE_NAME>` (using the role from `SELECT CURRENT_ROLE()`). Parse the JSON output from stdout.
249
+
Run `ddl_to_dcm.py` using the command from the **Tools** section above, with `--output-path <project_dir>/sources/definitions --group-files-by-type`. Add `--schema-list` if only specific schemas should be migrated, and `--object-types` if only specific object types should be migrated. If the user chose **owned-only** in Step 1, add `--role <ROLE_NAME>` (using the role from `SELECT CURRENT_ROLE()`). Parse the JSON output from stdout.
246
250
247
251
#### Workspaces mode
248
252
249
253
Replicate the logic of `ddl_to_dcm.py` inline using SQL queries and agent file writes:
250
254
251
-
1. **Discover objects:** `SHOW OBJECTS IN DATABASE`, `SHOW SCHEMAS IN DATABASE`, `SHOW SEMANTIC VIEWS IN DATABASE` (to exclude semantic views). Per schema: `SHOW TASKS`, `SHOW USER FUNCTIONS`, `SHOW USER PROCEDURES`, `SHOW SEQUENCES`, `SHOW FILE FORMATS`, `SHOW ALERTS`. If owned-only, filter by the `owner` column. Query `INFORMATION_SCHEMA.PROCEDURES`/`FUNCTIONS` to skip non-SQL callables.
255
+
1. **Discover objects:** `SHOW OBJECTS IN DATABASE`, `SHOW SCHEMAS IN DATABASE`, `SHOW SEMANTIC VIEWS IN DATABASE` (to exclude semantic views). Per schema: `SHOW TASKS`, `SHOW USER FUNCTIONS`, `SHOW USER PROCEDURES`, `SHOW SEQUENCES`, `SHOW FILE FORMATS`, `SHOW ALERTS`. If owned-only, filter by the `owner` column. Query `INFORMATION_SCHEMA.PROCEDURES`/`FUNCTIONS` to skip non-SQL callables. On `SHOW USER FUNCTIONS` rows, skip any row with `is_data_metric = 'Y'` (reported as UNSUPPORTED: `data metric function`). If the user provided an object-type allow-list, validate every value against the canonical set (`TABLE`, `VIEW`, `DYNAMIC TABLE`, `TASK`, `FUNCTION`, `PROCEDURE`, `SEQUENCE`, `FILE FORMAT`, `ALERT`, `TAG`, `STAGE`, `SCHEMA`, `GRANT`) before any scanning, and skip the discovery steps for types that are not allowed.
252
256
253
257
2. **Convert DDL:** For each object, run `GET_DDL`, replace `CREATE` with `DEFINE`, uppercase the type keyword, expand same-schema bare references to FQNs. For functions/procedures, use the signature form for `GET_DDL` and expand the bare name to a quoted FQN.
254
258
@@ -272,6 +276,7 @@ Review the generated definitions for objects that DCM does not support with DEFI
0 commit comments