feat: Remove pk index naming from postgres destination#20438
Conversation
|
🚀 PostgreSQL Cloud UI deployed to Vercel: |
erezrokah
left a comment
There was a problem hiding this comment.
Can we add some tests on migration existing tables with the old naming convention?
Sure, I think that can be done. |
|
@erezrokah Added the test checking if old index names are untouched after migration. |
| err := c.conn.QueryRow(ctx, `select tco.constraint_name from information_schema.table_constraints tco join information_schema.key_column_usage kcu | ||
| on kcu.constraint_name = tco.constraint_name | ||
| where tco.constraint_type = 'PRIMARY KEY' | ||
| and kcu.table_name = $1`, tableName).Scan(&pkConstraintName) |
There was a problem hiding this comment.
Maybe a nitpick but since the other queries are uppercased, let's uppercase this one as well.
…primary-key-in-the-postgres
🤖 I have created a release *beep* *boop* --- ## [8.8.0](plugins-destination-postgresql-v8.7.12...plugins-destination-postgresql-v8.8.0) (2025-03-27) ### Features * Remove pk index naming from postgres destination ([#20438](#20438)) ([5314c7a](5314c7a)) ### Bug Fixes * **deps:** Update module github.com/apache/arrow-go/v18 to v18.2.0 ([#20410](#20410)) ([ee081fb](ee081fb)) * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.74.2 ([#20434](#20434)) ([8db20d6](8db20d6)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Summary
This PR aims to solve issues with long table names in Postgresql database. All identifiers cannot be longer than 63 characters limit. Due to custom naming scheme of primary keys if table had more than 58 characters adding
_cqpkcaused DDLs to fail. To prevent that 2 things have been changed:_cqpkinstead we fallback to default postgres naming scheme of_pkeywhich gets auto-incremented in case of conflicting name. This change is backwards compatible as it's part of create if not exists DDL._cqpi. This change is also backwards compatible as table names longer than 58 characters couldn't be created due to_cqpkprimary key identifier preventing DDL statements to execute.