Skip to content

IBX-11939: Replaced the SERIAL conversion loop with plain SQL statements - #881

Merged
Steveb-p merged 1 commit into
6.0from
feature/schema-migration-identity-sql-6.0
Oct 12, 2026
Merged

Steveb-p merged 1 commit into
6.0from
feature/schema-migration-identity-sql-6.0

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-11939

Related PRs:

Description:

sql/convert-serial-columns-to-identity-postgresql.sql was a PL/pgSQL DO block that looped over the columns, read each one's sequence from information_schema and skipped a column that was no longer SERIAL. It now holds the plain statements for each column, so it can be read and run by hand:

ALTER TABLE ibexa_content ALTER id DROP DEFAULT;
ALTER SEQUENCE ibexa_content_id_seq RENAME TO ibexa_content_id_seq_old;
ALTER TABLE ibexa_content ALTER id ADD GENERATED BY DEFAULT AS IDENTITY;
SELECT setval('ibexa_content_id_seq', last_value, is_called) FROM ibexa_content_id_seq_old;
DROP SEQUENCE ibexa_content_id_seq_old;

The old sequence is renamed first, so the identity column's own sequence gets the usual <table>_<column>_seq name; its value is then carried over, and the old one is dropped.

The check moved to the migration. Doctrine DBAL 4 reports only identity columns as autoincrement (a SERIAL column comes back with its nextval() default instead), and PostgreSQL runs the migration in one transaction, so the first column tells whether the columns are converted already, as on a database a 6.0 SchemaBuilderEvent install created.

This changes a migration that is already on 6.0. 6.0 isn't released, so no site has run it yet.

Checked on PostgreSQL 16:

…nts (#881)

* IBX-11939: Replaced the SERIAL conversion loop with plain SQL statements

sql/convert-serial-columns-to-identity-postgresql.sql was a PL/pgSQL DO
block that looped over the columns, read each one's sequence from
information_schema and skipped a column that was no longer SERIAL. It
now holds the plain statements for each column, so it can be read and
run by hand.

The check moved to the migration. Doctrine DBAL 4 reports only identity
columns as autoincrement, and PostgreSQL runs the migration in one
transaction, so the first column tells whether the columns are converted
already, as on a database a 6.0 SchemaBuilderEvent install created.
@Steveb-p
Steveb-p force-pushed the feature/schema-migration-identity-sql-6.0 branch from fc04af9 to 2dfc55b Compare October 12, 2026 12:45
@Steveb-p
Steveb-p merged commit 2dfc55b into 6.0 Oct 12, 2026
8 checks passed
@Steveb-p
Steveb-p deleted the feature/schema-migration-identity-sql-6.0 branch October 12, 2026 12:46
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants