Repository navigation
Description
2026-11-25: in PR #197 (feat/117-roles-and-impact-table). Offline: 772 of the kernel's tests, 200 of the PostgreSQL package's, 90 of the second provider's; the API probes' 127. Live: 4 and 76 on PostgreSQL 16 and on 18, 86 on SQL Server 2022, the consumer smoke test's 47 rows. The live suites, the probes and the smoke test ran before the last test was added; nothing under src/ changed after them.
What is there:
Dependency.Column(Table, Name, Role)withColumnRole:Key,Expression,Condition,Included. The resolver saysKeyfor a column by itself andExpressionfor 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)withColumnAlteration, 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, andOther, 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.ImpactOfis one line that reads it, and the descriptor'sKeyColumnsis gone. Its answers are the ones it gave: every test ofPgExclusionMigrationTestsandPgExclusionLiveTestspasses 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. ImpactOfis 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.
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 |
Decided 2026-11-25 by the maintainer: the proposal below, as written. The role on Dependency.Column, what was altered on BaseChange.ColumnAltered, and the table as the PostgreSQL package's own; decision 8 stays.
Proposal, 2026-11-25, together with #116. A sentence that says "measured" names where; everything else is a recommendation. It proposes less than the issue below asks for: the table as a provider package's own, not as a mechanism of the kernel, so decision 8 stays as it is.
Where it stands
- One contributor ships,
PgExclusionContributor, and it answers seven changes. Its answer to a dropped column depends on how the column is read, and it keeps that beside its descriptor's comparison (KeyColumns, A column an expression element reads cannot be dropped: ImpactOf answers Lost, and PostgreSQL refuses the drop (2BP01) #102), since a dependency does not say it. - The second provider's SQL Server probe answers the same seven changes otherwise: a dropped or altered column is
RebuildAround, neverLost(measured on SQL Server 2022: Msg 5074, Msg 4922). Its audit names one thing the contract cannot say: aColumnAltereddoes not say what was altered, so a change of nullability alone, which SQL Server takes under an index unless the filter reads the column, rebuilds the index like a change of type. PgIndex(PgIndex: typed indexes with expression and JSON-member keys and typed filters #27) will be the second PostgreSQL contributor and would write the PostgreSQL answers a second time.
Proposed
1. A column dependency says how it is read. Dependency.Column(Table, Name, Role), the role one of: a key by itself, inside an expression, in the condition, an included column. A contributor states it where it composes its descriptor. PgExclusionDescriptor.KeyColumns goes: the role is what it stood for. A change to a case of a closed union of the contract.
2. An altered column says what was altered. BaseChange.ColumnAltered gains what the operation changed: the type, the nullability, the default, the collation, or something else. The kernel reads it from the operation and its OldColumn. Also a change to a case of a closed union.
3. The measured table is the provider package's, not the kernel's. ImpactOf stays mandatory and abstract, and no cell has a default in the kernel. The PostgreSQL package gets one internal table keyed by object kind, role and change, which its contributors' ImpactOf read; a cell the table lacks is RebuildAround. PgExclusionContributor and later PgIndex then write no answer of their own. The table's test is the live server, as PgExclusionLiveTests is today for each way of reading a column; spike E's cells for an index and a trigger move there with the contributors that need them.
4. The second provider's probes answer from the roles and from what was altered, as the evidence that the two contract changes say enough: on SQL Server a change of nullability alone leaves an index whose filter does not read the column.
What this leaves out, on purpose
- A table registered with the kernel, with a default for a cell nobody measured. It reopens decision 8 for a gain only a third party's contributor has, and the contract guide (What a third party needs to ship a contributor: a contract guide, the oracles as a testing package, and rc.1 as a gate #120) can hand such a contributor the package's table as a pattern. If a kernel-level default is wanted later, the roles and the altered aspects are what it would be keyed by, so nothing here is in its way.
- A refusal where an object cannot be dropped before the first touch and created after the last. That needs the one ordered list of The plan as ordered actions with a name ledger, not two lists around EF Core's operations #115's slice C.
Questions for the maintainer
- Are the two contract changes accepted, the role on
Dependency.Columnand what was altered onBaseChange.ColumnAltered? - Is the table as the provider package's own enough, with decision 8 left as it is?
Before preview.2, when PgIndex would write the table a second time. From the architecture debate of 2026-11-14; not decided. Reopens decision 8 (Plan and ImpactOf mandatory, no default answer).
Problem
ImpactOf(descriptor, change) asks each contributor what the database does to its object when a column or a table changes. That is the database's behaviour, and each contributor writes it down by hand. Three defects were one more cell each: #80 (an alter written as drop and add), #81 (a type change that begins to need an extension), #102 (a column read through an expression is not dropped with the constraint but refuses the drop). PgIndex and SqlServerIndex would each write the table again, and PostgreSQL treats an index's predicate and an exclusion constraint's differently.
Change, to decide
- A column dependency says how it is read: as a key by itself, inside an expression, in the predicate, as an included column.
- One measured table per provider, keyed by object kind, role and change, answers the standard cases. Spike E is that table's test, extended by the cells it lacks (the expression element, nullable to not null, a computed column, SQLite).
- A contributor overrides a cell and otherwise writes none.
Planstays mandatory. - A cell nobody measured is drop before and create after, and where the object cannot be dropped before the first touch and created after the last, the migration is refused.
Decision 8's reason was an optional hook that answered "unaffected" by default and lost objects. A default of drop and recreate fails the other way: a rebuild that was not needed, never an object that is gone. GPT held ImpactOf mandatory in the first round and withdrew it on the condition of point 4 and of object kind in the key.
Done when
PgExclusionContributor writes no cell of its own that the table holds, #102's two pairs apply on PostgreSQL 16 and 18, and the second provider answers from its own table: on SQL Server a dropped column under an index is drop before and create after, never Lost.
Activity