Skip to content

feat: Assess Microsoft SQL Server schema impact without a database connection - #23466

Draft
erezrokah wants to merge 1 commit into
mainfrom
ath-956-assess-microsoft-sql-server-impact-from-its-type-mappings
Draft

erezrokah wants to merge 1 commit into
mainfrom
ath-956-assess-microsoft-sql-server-impact-from-its-type-mappings

Conversation

@erezrokah

Copy link
Copy Markdown
Member

Implements the plugin-sdk Assessor in the Microsoft SQL Server destination, classifying each table and column change with the same type mapping (queries.SQLType), normalization and unsafeChanges rules migrate uses, for safe and forced modes, without a database connection.

Fixes https://linear.app/env-zero/issue/ATH-956/assess-microsoft-sql-server-impact-from-its-type-mappings-and

@erezrokah

Copy link
Copy Markdown
Member Author

Deviations from the PostgreSQL assessor (#23463), and why:

  • Source-only column changes are reported as NoChange columns. SQL Server maps both list<string> and json to nvarchar(max), so Datadog v5.19.10→v6.0.0 datadog_monitors.tags is a no-op for migrate. Without this, the finding would have no columns and would not show the SQL Server types. The table is No destination schema change, with tags: nvarchar(max) → nvarchar(max), "makes no changes".
  • normalizeTable clears Unique. The plugin never creates unique constraints, so a table read back from SQL Server never has one. Without this, a removed source unique constraint would report Manual migration required, but migrate makes no change.
  • No rule extraction. unsafeChanges/needsTableDrop (client/changes.go) and normalizeTable (client/schema.go) are already package-level and pure, so the assessor calls them directly.
  • Close returns early when db is nil, because a no_connection client has no DB or writer.

Verification:

  • make test passed (client and queries packages, against SQL Server 2019 in Docker).
  • golangci-lint run --config ../../.golangci.yml: no issues.
  • I broke the Unique normalization on purpose. TestAssessTablesRemovedUniqueConstraint failed, and passed again after I restored it.
  • I ran a throwaway live test (not committed) against the same Docker SQL Server. It compared each assessment to a real safe-mode MigrateTables:
    • list<string> → json: NoChange, and migrate succeeded.
    • int → bigint: ManualMigrationRequired, and migrate rejected it.
    • Added nullable column: AutomaticallyMigratable, and migrate succeeded.

plugin-sdk is pinned to the unreleased ath-938-add-the-destination-assessment-interface-and-server-wiring branch (cloudquery/plugin-sdk#2618). ATH-985 replaces it with a release.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant