Altered serial columns break sequences

Created on 14 June 2010, about 14 years ago
Updated 11 April 2023, over 1 year ago

PostgreSQL uses sequences to track the current value of a serial column. When a serial column is created, a sequence is automatically created with a naming convention of {table_name}_{column_name}_seq. However, this sequence doesn't get renamed when a column is renamed. Therefore, a sequence belonging to a serial column that is changed by the schema API will no longer be accessible.

For example, I take a serial column called "test_column" and rename it to "test_column_old". The serial will still be called "test_column_old". Then I create a new serial column called "test_column". PostgreSQL will create a new sequence called "{table_name}_test_column_seq1" because "{table_name}_test_column_seq" already exists. This means, when Drupal tries to access that columns sequence, it will access what the schema API knows and not the correct sequence for either columns.

I think we need to add checks to move/delete sequences along with serial columns.

🐛 Bug report
Status

Closed: duplicate

Version

10.1

Component
PostgreSQL driver 

Last updated 10 days ago

No maintainer
Created by

🇳🇿New Zealand Josh Waihi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024