Repository navigation
Spike D: SqlOperations in idempotent scripts and bundles - #146
Merged
Merged
Conversation
…r and its script For #19 and point 4 of #115. The consumer writes a contributor against the kernel's public contract, so its statements reach a migration through SchemaKit's planner and differ; run.sh packs the packages, drives dotnet ef from outside the repository and judges every run by the catalog. The table is not measured yet. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…r's cells from CI The judge reports the server's own words, the table's state is part of each cell, and a body with line breaks through EXEC is measured as well. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… and a bundle's exit code The judge's way of applying a script is held against the provider's own client where the machine has one. A trigger's body as the catalog keeps it is compared across the paths. A bundle's exit code was read from the wrong command; a failing bundle is now reported as one. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The table is measured on PostgreSQL 16 and 18 and SQL Server 2022, on a developer's machine and in CI, and held by run.sh. CLAUDE.md lists the spike and its command; the plan's row D says what was measured. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…llow-up issues Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
CaffeinatedCoder
marked this pull request as ready for review
November 16, 2026 13:31
…carries on SQL Server A database that cannot be created is a failing row for each path, where before the cells went missing from a run that then reported every cell. A run with a server nobody named says NOT MEASURED in its last line. An index on SQL Server is told apart by its rowset's id, and every identity is shown to change when the object is dropped and created again. The annotation checks hold all five, the object's among them, and the snapshot and the designer file have to be there. SQL Server's online index is built inside a transaction too, so it never said whether the suppression arrives. ALTER DATABASE … ALLOW_SNAPSHOT_ISOLATION, which the server refuses in a transaction, does: suppressed it applies on every path, and the control without the suppression fails on every path. The provider's own client is reached on PATH or in the server's container, and uses_quoted_identifier of a trigger sqlcmd created is held beside the cell. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19
Problem
Every object SchemaKit creates reaches a migration as a
SqlOperationrendered at design time (plan, decision 4). Whether one that suppresses the transaction, and a trigger, survivemigrations script --idempotentapplied twice and a migrations bundle run twice was not measured, on PostgreSQL or on SQL Server.concurrently:ofpreview.2(#27) and the row guard's trigger (#47) rest on the answer. Point 4 of #115 asks a second thing nobody had measured: what EF Core does with an annotation on aSqlOperation.Change
spikes/D.ScriptsAndBundles, in the manner of spikes B and E. Nothing undersrc/changes.consumer/is a project a consumer could write.Kit.csis a contributor against the kernel's public contract, so its statements reach the migration through the planner andSchemaKitModelDiffer.Program.csis the judge: it reads the catalog and applies a script the way psql and sqlcmd apply one.run.shpacks both packages, copies the consumer out of the repository once for each provider and statement, drivesdotnet ef, and applies each script and each bundle twice in a database of its own. It holds the table: a cell that answers otherwise fails the run. Where psql or sqlcmd can be reached, on PATH or in the server's container, every script goes through the tool itself as well.README.mdhas both questions, how to run it, the tables, and each error with the SQL that caused it.CLAUDE.mdlists the spike and its command; the plan's row D says what was measured.CI's spikes lane runs it with no change to the workflow:
run.shreads spike E's connection strings where its own are not set.What it measured
EF Core
11.0.0-rc.3, on PostgreSQL 16 and 18 and SQL Server 2022, on a developer's machine and in CI, with the same answer in both places. A bundle carries the statements of the question. A script does not carry two of them:CREATE INDEX CONCURRENTLY, transaction suppressedmigrations script --idempotent25001, refused inside theDOblock. psql goes on and exits 0: the migration is recorded, the index is missingCREATE TRIGGERmigrations script111: a migration is one batch, and nothing of it is appliedmigrations script --idempotent156: the samePostgreSQL's trigger with its function applies on every path, and the second run changes nothing. So does a statement with the transaction suppressed on SQL Server:
ALTER DATABASE CURRENT SET ALLOW_SNAPSHOT_ISOLATION ON, which the server refuses inside a transaction, applies on every path suppressed and fails on every path without. On SQL Server the trigger survives every path insideEXEC(N'…'), which the contract can write for a statement on one line only; with line breaks what it writes is not valid T-SQL and fails in the bundle too. The full table is in the README and on #19.The annotation:
migrations addwrites it as.Annotation(…)onmigrationBuilder.Sql(…), inUpand inDown, and the generator inside SchemaKit's decorator receives it atmigrations script, at--idempotentand when a bundle applies the migration, on Npgsql, SQL Server and SQLite. The answer is on #115.The spike builds no refusal. What has to be built is #155 (PostgreSQL) and #156 (SQL Server).
Tests
The spike is the measurement, so what holds it is how it is judged:
run.shpasses locally on all three servers and in CI's spikes lane.After the analysis of this PR
An independent analysis reproduced every cell and found defects in the harness and in the wording. No published cell changed. Each was reproduced before it was fixed:
Createmade to throw for every database after the first, the run fails with one row for each path.NOT MEASURED: …and claims only what was measured.CREATE INDEX … WITH (ONLINE = ON)never tested suppression: SQL Server builds it inside a transaction too. TheALTER DATABASErows and their control are new, and An idempotent script cannot carry a statement with the transaction suppressed on PostgreSQL: the migration is recorded without its index #155 no longer rests on the online index.object_idandindex_id, which a drop and create keeps. It is now the rowset's id.uses_quoted_identifier0, and 1 from a bundle; and on SQL Server a statement that fails at run time does not end its batch, so the script records the migration with that statement never run.One defect of the script's own was found before that and fixed: it read a bundle's exit code from the wrong command.
🤖 Generated with Claude Code