Skip to content

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

Done

Description

@CaffeinatedCoder

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) 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.

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

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

Questions for the maintainer

  1. Are the two contract changes accepted, the role on Dependency.Column and what was altered on BaseChange.ColumnAltered?
  2. 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

  1. A column dependency says how it is read: as a key by itself, inside an expression, in the predicate, as an included column.
  2. 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).
  3. A contributor overrides a cell and otherwise writes none. Plan stays mandatory.
  4. 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

  1. added this to the 11.0.0 milestone on Nov 14, 2026
  2. added
    enhancement
    package/core
    package/postgresql
    package/sqlserver
    area/migrations
    on Nov 14, 2026
  3. added
    breaking
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/migrationsbreakingenhancementpackage/corepackage/postgresqlpackage/sqlserver

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions