Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased]

### Fixed
- Script schema-level permissions after schema creation and before schema extended properties.
- Match legacy non-canonical schema-less object filenames to the scripted object name when the canonical name requires percent escaping.
- Allow bare `--object` selectors with dotted schema-less names (for example assemblies) to resolve correctly during targeted `status`, `diff`, and `pull`.
- Treat equivalent queue option formatting, explicit default `ON [PRIMARY]`, and disabled default activation as compatible during comparison.
- Treat equivalent role-membership statements written as `EXEC sp_addrolemember ...` or `ALTER ROLE ... ADD MEMBER ...` as compatible during comparison.
- Treat legacy Service Broker message-type validation synonyms and equivalent contract/service body formatting and item ordering as compatible during comparison.
- Treat equivalent `TableData` scripts as compatible during comparison when the normalized `INSERT` statements differ only by row ordering within the same contiguous data block.
- Treat equivalent `Table` scripts as compatible during comparison when post-create statement packages differ only by ordering after the base `CREATE TABLE` block.
- Treat omitted `TEXTIMAGE_ON` on `Table` scripts as compatible during comparison only when DB metadata shows the table LOB data space matches the current default data space.
- Treat equivalent extended-property blocks as compatible during comparison when the normalized `sp_addextendedproperty` statements differ only by ordering, argument spacing, or named-vs-positional argument forms within the same contiguous block.
- Treat redundant empty or otherwise no-op `GO` batches as compatible during comparison.
- Treat legacy explicit `NULL` tokens on CLR table-valued function return columns as compatible during comparison and preserve them during compatibility reconciliation when the rest of the definition matches.
- Trailing semicolon differences on `INSERT` statement lines in data scripts are now suppressed during comparison normalization; scripts emitted with and without statement terminators compare as compatible (#47).
- Legacy `TableData` scripts now compare as compatible when they differ from canonical output only by `SET IDENTITY_INSERT` semicolons or top-level `N'...'` string literal prefixes, including inside multi-line `INSERT ... VALUES (...)` statements.
- Whitespace-only separator lines now compare as compatible with empty blank lines during `status` and `diff`.
- Preserve reference banner-comment formatting and module-declaration identifier quoting during programmable-object compatibility reconciliation.
- Preserve compatible computed-column arithmetic grouping parentheses during table compatibility reconciliation.

### Added
- Discover and script SQL CLR scalar functions as `Function` objects.
- Discover and script SQL CLR table-valued functions as `Function` objects.
- Discover and script SQL CLR stored procedures as `StoredProcedure` objects.
- Discover and script built-in `dbo` as a `Schema` object when it has explicit schema permissions or schema-level extended properties, without emitting `CREATE SCHEMA`.
- `sqlct init` now prompts interactively for connection details (server, database, auth, credentials, trust-server-certificate) when run without flags in a new project directory (#36).
- Connection flags (`--server`, `--database`, `--auth`, `--user`, `--password`, `--trust-server-certificate`) for non-interactive/scripted `init` use (#36).
- `--skip-connection-test` flag for `sqlct init` to bypass the connection test step (#36).
Expand All @@ -22,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- SQL Authentication support: set `database.auth` to `"sql"` and supply `database.user` (and optionally `database.password`) in `sqlct.config.json` to connect using SQL Server Authentication (#30).
- Support active object type `Assembly`, with deterministic scripting to `Assemblies/*.sql` for user-defined SQL Server assemblies.
- Support additional active object types: `TableType`, `XmlSchemaCollection`, `MessageType`, `Contract`, `Queue`, `Service`, `Route`, `EventNotification`, `ServiceBinding`, `FullTextCatalog`, `FullTextStoplist`, and `SearchPropertyList`.
- Script standalone user-created table statistics as deterministic post-create table statements, including filtered, effective sampling, persisted-sample, incremental, and auto-drop metadata when available.
- Add `--object <pattern>` to `sqlct data track` and `sqlct data untrack` as a flag alias for the positional pattern argument.
- Add `--filter <regex>` to `sqlct data track` and `sqlct data untrack` for regex-based table matching; matched case-insensitively against the full `schema.table` display name. Exactly one of the positional pattern, `--object`, or `--filter` must be provided; combining any two returns exit code 2.
- `sqlct diff` now uses a chunked diff format: only changed segments and configurable surrounding context lines are shown instead of the full file. Use `--context <N>` to control the number of context lines (default: 3) (#39).
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ Current runtime scope for `status`, `diff`, and `pull` covers:
- `FullTextStoplist`
- `SearchPropertyList`

Schema scripting covers user-defined schemas and also emits built-in `dbo` when it has explicit schema permissions or schema-level extended properties; `dbo` is scripted without `CREATE SCHEMA`.

Stored procedure scripting covers T-SQL procedures and SQL CLR stored procedures (`sys.objects.type = 'P'` and `PC`).

Table scripting also includes standalone user-created table statistics (`CREATE STATISTICS`) as post-create table statements. Current statistics option coverage includes effective sampling (`FULLSCAN` or `SAMPLE <n> PERCENT`), `PERSIST_SAMPLE_PERCENT = ON`, `NORECOMPUTE`, `INCREMENTAL=ON`, and `AUTO_DROP = ON|OFF` when the source server exposes the required metadata. `MAXDOP`, `STATS_STREAM`, `ROWCOUNT`, and `PAGECOUNT` remain deferred.

Function scripting covers T-SQL scalar/table functions and SQL CLR scalar/table-valued functions (`sys.objects.type = 'FS'` and `FT`), including `EXTERNAL NAME` assembly bindings.

When `data.trackedTables` is configured, `status`, `diff`, and `pull` also process `TableData` artifacts for those explicit tracked tables.

`--object` selectors support:
Expand Down
22 changes: 20 additions & 2 deletions specs/01-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,17 @@ Behavior:
- Deleted: object exists only in target.
- Changed: normalized script content differs.
- Suppress changes when scripts are identical after normalization.
- Normalization in v1 is limited to line-ending/trailing-newline stability for deterministic comparison.
- Normalization includes line-ending/trailing-newline stability plus explicitly listed compatibility rules for deterministic comparison.
- Whitespace-only lines are normalized to empty lines during comparison so blank separators with spaces or tabs compare as compatible.
- Redundant empty or no-op `GO` batches compare as compatible.
- Trailing semicolons on `INSERT` statement lines are stripped during normalization; scripts emitted with and without statement terminators compare as compatible.
- Equivalent `TableData` `INSERT` statement ordering within the same contiguous data block compares as compatible when the inserted row set is otherwise identical.
- Equivalent `Table` post-create statement package ordering compares as compatible when the normalized package set after the base `CREATE TABLE` block is otherwise identical.
- For `Table`, omitted `TEXTIMAGE_ON [name]` compares as compatible with an explicit clause only when DB metadata shows that the table LOB data space equals the current default data space represented by `[name]`.
- Equivalent extended-property statement ordering within the same contiguous extended-property block compares as compatible when the normalized property statement set is otherwise identical. Equivalent named-vs-positional `sp_addextendedproperty` argument forms, including omitted trailing `NULL` levels, compare as compatible.
- Equivalent `Queue` option spacing, line wrapping, explicit default `ON [PRIMARY]`, and disabled default activation compare as compatible.
- Equivalent `Role` membership statements written as `EXEC sp_addrolemember ...` or `ALTER ROLE ... ADD MEMBER ...` compare as compatible.
- Equivalent `MessageType` validation synonyms/spacing and equivalent `Contract` and `Service` body formatting and item ordering compare as compatible.
- When `data.trackedTables` is configured, `status` also reports data-script differences for tracked tables.
- Status output MUST report schema and data summaries separately.
- Exit codes:
Expand All @@ -216,8 +225,17 @@ Behavior:
- Without `--object`, output concatenated per-object diffs in stable order.
- Changed objects use DB-vs-folder unified diff.
- Added/deleted objects use empty-side vs script-side unified diff.
- Normalization in v1 is limited to line-ending/trailing-newline stability for deterministic comparison.
- Normalization includes line-ending/trailing-newline stability plus explicitly listed compatibility rules for deterministic comparison.
- Whitespace-only lines are normalized to empty lines during comparison so blank separators with spaces or tabs compare as compatible.
- Redundant empty or no-op `GO` batches compare as compatible.
- Trailing semicolons on `INSERT` statement lines are stripped during normalization; scripts emitted with and without statement terminators compare as compatible.
- Equivalent `TableData` `INSERT` statement ordering within the same contiguous data block compares as compatible when the inserted row set is otherwise identical.
- Equivalent `Table` post-create statement package ordering compares as compatible when the normalized package set after the base `CREATE TABLE` block is otherwise identical.
- For `Table`, omitted `TEXTIMAGE_ON [name]` compares as compatible with an explicit clause only when DB metadata shows that the table LOB data space equals the current default data space represented by `[name]`.
- Equivalent extended-property statement ordering within the same contiguous extended-property block compares as compatible when the normalized property statement set is otherwise identical. Equivalent named-vs-positional `sp_addextendedproperty` argument forms, including omitted trailing `NULL` levels, compare as compatible.
- Equivalent `Queue` option spacing, line wrapping, explicit default `ON [PRIMARY]`, and disabled default activation compare as compatible.
- Equivalent `Role` membership statements written as `EXEC sp_addrolemember ...` or `ALTER ROLE ... ADD MEMBER ...` compare as compatible.
- Equivalent `MessageType` validation synonyms/spacing and equivalent `Contract` and `Service` body formatting and item ordering compare as compatible.
- Diff output uses a chunked format: only changed lines and their surrounding context are shown, not the entire file.
- `--context <N>` controls the number of unchanged context lines shown before and after each changed segment (default: 3). Negative values are treated as 0.
- When two change segments are close enough that their context regions overlap, they are merged into a single hunk.
Expand Down
1 change: 1 addition & 0 deletions specs/03-schema-folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Defines the baseline `sqlct` schema-folder structure and naming rules.
- Data tracking uses `Data/` for scripts derived from tables explicitly listed in `data.trackedTables`.
- Schema-less objects omit the schema prefix (e.g., `Assemblies/AppClr.sql`, `Security/Schemas/AppSecurity.sql`, `Security/Roles/AppReader.sql`, `Storage/Partition Functions/FiscalYear_PF.sql`, `Storage/Full Text Catalogs/DocumentCatalog.sql`, `Storage/Search Property Lists/DocumentProperties.sql`, `Service Broker/Contracts/%2F%2FApp%2FMessaging%2FContract.sql`, `Service Broker/Services/AppInitiatorService.sql`, `Service Broker/Event Notifications/NotifySchemaChanges.sql`, `Service Broker/Remote Service Bindings/AppRemoteBinding.sql`).
- Replace invalid file name characters in `Schema` or `Object` with percent-encoded hex (e.g., `:` -> `%3A`, `/` -> `%2F`).
- Folder readers MAY recover object identity for legacy schema-less files whose names are not canonical percent-encoded paths by reading the top-level `CREATE` statement when the scripted object name contains characters that require escaping; writers MUST continue to use canonical percent-encoded file names.
- Folder names and casing must remain stable within a project.
- Line endings must match existing output (typically CRLF); do not force-normalize.
- Object matching is case-insensitive.
Expand Down
Loading
Loading