Skip to content

feat!: a column dependency says how it is read, an altered column what was altered - #197

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
feat/117-roles-and-impact-table
Nov 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
feat/117-roles-and-impact-table

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #117

Decided 2026-11-25 with #116.

Problem

ImpactOf asks each contributor what the database does to its object when a column or a table changes. Two things the contract could not say: how an object reads a column, which the exclusion contributor kept beside its descriptor (#102), and what an AlterColumnOperation altered, so that on SQL Server a default or a change of nullability took an index away and built it again for nothing (#119). And a second PostgreSQL contributor would write PostgreSQL's answers a second time.

Change

  • Dependency.Column(Table, Name, Role) with ColumnRole: Key, Expression, Condition, Included. The resolver says Key for a column by itself and Expression for one in a template; SqlFragment.As(role) says the others where a contributor puts a fragment. Read in two ways, a column is two dependencies. The role has a default, Key, so a dependency made by hand reads as before.
  • BaseChange.ColumnAltered(Table, Column, What) with ColumnAlteration, flags read from the operation's two sides: Type (a length, precision, scale, character set and fixed length are part of it), Nullability, Default, Collation, and Other, which is what is left and never nothing.
  • PgImpact, the PostgreSQL package's one table, keyed by the object's kind, the column's role and the change. PgExclusionContributor.ImpactOf is one line that reads it, and the descriptor's KeyColumns is gone. Its answers are the ones it gave: every test of PgExclusionMigrationTests and PgExclusionLiveTests passes unchanged.
  • The second provider's SQL Server probe answers from both: a default and a change of nullability leave the index where it is, unless its filter reads the column. Measured on SQL Server 2022: left alone, a change of nullability of the filter's column is refused with Msg 5074 and Msg 4922, and with the index out of its way the migration applies and leaves what EnsureCreated() builds.
  • ImpactOf is mandatory as before, and the kernel has no table and no default.

Not held by a behaviour: that PgExclusionContributor reads its condition's columns as Condition and not as Expression. PostgreSQL answers both alike for an exclusion constraint, so no migration differs. The_packages_table_answers_a_dropped_column_by_the_way_it_is_read holds the table's rows for each role; the role the contributor states for the condition matters first with PgIndex (#27), whose predicate PostgreSQL treats otherwise.

Tests

Offline: 772 (kernel), 200 (PostgreSQL package), 90 (second provider); the API probes: 127. Live: 4 and 76 on PostgreSQL 16 and on 18, 86 on SQL Server 2022. The consumer smoke test: 47 rows. The live suites, the probes and the smoke test ran before the last test was added; nothing under src/ changed after them.

Thirteen rules were changed in turn, each run with the live tests on PostgreSQL 18 and SQL Server 2022. A test failed for twelve:

Changed Fails
A column in a template is read by itself 9 of the kernel's, 4 of the PostgreSQL package's
A column by itself is read in an expression 5 of the kernel's, 4 of the PostgreSQL package's
As changes no role A_fragment_composed_of_others_reads_what_they_read, 12 of the second provider's
The condition's columns keep the template's role none: see above
A dropped key column is taken out of the way 4 of the PostgreSQL package's
A dropped expression column takes the constraint with it 4
A dropped condition column takes the constraint with it 4
The key's row stands behind the expression's A_dropped_column_that_is_an_element_takes_the_constraint_with_it_whatever_else_reads_it
A cell no row answers is unaffected A_filter_of_5x_may_read_a_column_it_does_not_name_by_a_path
Every alteration is of the type An_altered_column_says_what_was_altered, two of the second provider's
An alteration of nothing known is nothing An_altered_column_says_what_was_altered
SQL Server: the filter's column counts as any other 15 of the second provider's
SQL Server: every alteration takes the index away two

breaking: Dependency.Column and BaseChange.ColumnAltered each have a new member, in the contract (SK9001).

🤖 Generated with Claude Code

…t was altered

Dependency.Column has a ColumnRole: a key by itself, in an expression, in
the condition, an included column. The resolver says the first two and
SqlFragment.As the others. BaseChange.ColumnAltered has a ColumnAlteration
read from the operation's two sides: the type, the nullability, the
default, the collation, or something else.

The PostgreSQL package answers ImpactOf from one table, PgImpact, keyed
by the object's kind, the column's role and the change. The exclusion
contributor writes no answer of its own and gives the ones it gave.
ImpactOf stays mandatory; the kernel has no table and no default.

The second provider's SQL Server probe answers from both: a default and
a change of nullability leave an index where it is, unless its filter
reads the column.

Closes #117

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 25, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request breaking Changes an answer or a signature package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL package/sqlserver Affects CodoMetis.EFCore.SchemaKit.SqlServer area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 5870821 into main Nov 25, 2026
11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/117-roles-and-impact-table branch November 25, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring breaking Changes an answer or a signature enhancement New feature or request package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) package/postgresql Affects CodoMetis.EFCore.SchemaKit.PostgreSQL package/sqlserver Affects CodoMetis.EFCore.SchemaKit.SqlServer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impact from a measured table per provider, keyed by object kind, role and change

1 participant