Complete workflow for migrating database tables, views, and stored procedures to dbt projects on Snowflake...
Guide AI agents through the complete migration lifecycle from Snowflake or legacy database systems (SQL Server, Oracle, Teradata, etc.) to production-quality dbt projects on Snowflake. This skill defines a structured, repeatable process while delegating platform-specific syntax translation to dedicated source-specific skills.
Activate this skill when users ask about:
IMPORTANT: For all supported platforms listed below, SnowConvert AI is a hard requirement — do not attempt manual conversion. SnowConvert AI handles edge cases, platform-specific idioms, and dependency resolution that manual translation consistently misses.
SnowConvert AI converts source DDL, views, stored procedures, functions, and additional objects (triggers, sequences, indexes) to Snowflake-compatible SQL. Download SnowConvert AI
| Tool | Purpose |
|---|---|
| AI Code Conversion | AI-powered validation and repair of converted code |
| Migration Assistant | VS Code extension for resolving conversion issues (EWIs) |
| Data Migration | Transfer data to Snowflake (SQL Server, Redshift) |
| Data Validation | GUI-based validation (SQL Server) |
| Data Validation CLI | CLI validation (SQL Server, Teradata, Redshift) |
| ETL Replatform | Convert SSIS packages to dbt projects |
| Power BI Repointing | Redirect Power BI reports to Snowflake |
CRITICAL: Migrated dbt models must preserve the original SQL object names from the source database. Do not rename tables, views, or columns during migration.
alias config if the file
name must differ from the target object name.int_ prefix but keep the base name intact (e.g., int_original_name__step1).Name retention ensures that downstream consumers (reports, applications, APIs) continue to work without modification after migration. It also simplifies validation by allowing direct name-based comparison between source and target systems.
The migration process follows seven sequential phases. Each phase has entry criteria, deliverables, and validation gates that must pass before advancing.
1-Discovery → 2-Planning → 3-Placeholders → 4-Views → 5-Table Logic → 6-Testing → 7-Deployment
Create a complete inventory of source database objects and understand dependencies, volumes, and complexity to inform migration planning.
SnowConvert AI Requirement: For supported platforms, SnowConvert AI provides extraction scripts that automate object inventory, dependency mapping, and initial code conversion. Use it — do not skip this step for supported platforms.
| Complexity | Criteria | Examples |
|---|---|---|
| Low | Simple SELECT, no/minimal joins | Lookup tables, simple views |
| Medium | Multiple joins, aggregations, CASE | Summary views, report queries |
| High | Procedural logic, cursors, temp tables | SCD procedures, bulk loads |
| Custom | Platform-specific features | Wrapped code, CLR functions |
Organize legacy scripts, map objects to the dbt medallion architecture, and establish naming conventions before any conversion begins.
| Source Object Type | Target Layer | dbt Prefix | Materialization |
|---|---|---|---|
| Source tables (raw) | Bronze | stg_ |
ephemeral |
| Simple views | Bronze | stg_ |
ephemeral |
| Complex views | Silver | int_ |
ephemeral/table |
| Dimension procedures | Gold | dim_ |
table |
| Fact procedures | Gold | fct_ |
incremental |
Create empty dbt models with correct column names, data types, and schema documentation before adding any transformation logic. This establishes the contract for downstream consumers.
null::datatype as column_name pattern
and where false_models.yml with column descriptions and testsdbt compile --select tag:placeholderplaceholder tag to config for tracking{{ config(materialized='ephemeral', tags=['placeholder', 'bronze']) }}
select
null::integer as column_id,
null::varchar(100) as column_name,
-- ... additional columns with explicit types
where false
_models.yml created with descriptions and testsConvert source database views to dbt models, starting with simple views before tackling complex ones. Views are typically easier than stored procedures as they contain declarative SQL.
_models.yml using $dbt-testing skill patternsTransform procedural stored procedure logic into declarative dbt models, selecting appropriate materializations for different ETL patterns.
| Source Pattern | dbt Approach |
|---|---|
| TRUNCATE + INSERT | materialized='table' |
| UPDATE + INSERT (SCD1) | materialized='incremental' with merge |
| SCD Type 2 | dbt snapshot or custom incremental |
| INSERT only | materialized='incremental' append |
| DELETE range + INSERT | incremental with delete+insert strategy |
| Procedural Pattern | dbt Equivalent |
|---|---|
| CURSOR loop | Window function or recursive CTE |
| Temp tables | CTEs or intermediate models |
| Variables | Jinja variables or macros |
| IF/ELSE branches | CASE expressions or {% if %} |
| TRY/CATCH | Pre-validation tests |
Verify that migrated dbt models produce identical results to source system, using multiple validation techniques to ensure data integrity.
Snowflake Data Validation CLI: For SQL Server, Teradata, or Redshift migrations, the Data Validation CLI provides automated schema validation (columns, data types, row counts) and metrics validation (MIN, MAX, AVG, NULL count, DISTINCT count).
| Technique | Purpose | Implementation |
|---|---|---|
| Row counts | Detect missing/extra rows | Compare COUNT(*) |
| Checksums | Detect value differences | SHA2 hash comparison |
| Business rules | Verify logic accuracy | Singular tests |
| Aggregates | Validate totals | SUM/AVG comparisons |
| Mock data | Test transformations | Seed files + expected outputs |
Deploy validated dbt models to production with a clear cutover plan and monitoring strategy.
dbt build --target dev and validate--store-failures| Phase | Activities |
|---|---|
| Pre-Cutover (T-1) | Final validation, stakeholder sign-off, rollback docs, user communication |
| Cutover (T-0) | Disable source ETL, final sync, deploy, build, validate, update BI connections |
| Post-Cutover (T+1) | Monitor performance, verify schedules, confirm access, close tickets |
| Rollback | Re-enable source ETL, revert BI connections, document issues |
For syntax translation, delegate to the appropriate source-specific skill:
| Source Platform | Skill | Key Considerations |
|---|---|---|
| Snowflake | $dbt-migration-snowflake | Convert Snowflake objects to dbt |
| SQL Server / Azure Synapse | $dbt-migration-ms-sql-server | T-SQL, IDENTITY, TOP, #temp tables |
| Oracle | $dbt-migration-oracle | PL/SQL, ROWNUM, CONNECT BY, packages |
| Teradata | $dbt-migration-teradata | QUALIFY, BTEQ, volatile tables |
| BigQuery | $dbt-migration-bigquery | UNNEST, STRUCT/ARRAY, backticks |
| Redshift | $dbt-migration-redshift | DISTKEY/SORTKEY, COPY/UNLOAD |
| PostgreSQL / Greenplum / Netezza | $dbt-migration-postgres | Array expressions, psql commands |
| IBM DB2 | $dbt-migration-db2 | SQL PL, FETCH FIRST, handlers |
| Hive / Spark / Databricks | $dbt-migration-hive | External tables, PARTITIONED BY |
| Vertica | $dbt-migration-vertica | Projections, flex tables |
| Sybase IQ | $dbt-migration-sybase | T-SQL variant, SELECT differences |
| Phase | Key Deliverable | Exit Criteria | Primary Skill | Validation Focus | Validation Command |
|---|---|---|---|---|---|
| 1. Discovery | migration_inventory.csv, dependency graph |
Inventory complete, dependencies mapped | This skill | Object counts, dependency completeness | Manual review |
| 2. Planning | Folder structure, _naming_conventions.md |
Folder structure created, naming defined | $dbt-architecture | Folder hierarchy, naming conventions | ls -la models/ |
| 3. Placeholders | .sql files, _models.yml |
All models compile with where false |
This skill | YAML structure, column definitions, naming | dbt compile --select tag:placeholder |
| 4. Views | Converted view models | All views converted and compile | dbt-migration-{source}, $dbt-modeling | Syntax translation, CTE patterns, ref() usage | dbt build --select tag:view |
| 5. Table Logic | Converted procedure models | All procedures converted | $dbt-materializations | Incremental configs, materialization patterns | dbt build --select tag:procedure |
| 6. Testing | Validation queries, test results | All validation queries pass | $dbt-testing, $dbt-performance | Test coverage, constraint definitions | dbt test --store-failures |
| 7. Deployment | Production models, monitoring | Production deployment successful | $dbt-commands, $snowflake-cli | Run success, schedule configuration | dbt build --target prod |
CRITICAL: Agents must not advance to the next phase until all validations pass.
Before proceeding to each phase, verify:
dbt compile succeedsdbt test passesHook configuration is defined in .claude/settings.local.json.