terraform-provider-postgresql
terraform-provider-postgresql copied to clipboard
`data.postgresql_sequences` does not show column identity sequences
Hi there,
Thank you for opening an issue. Please provide the following information:
Terraform Version
- Terraform v1.6.3
- terragrunt version v0.53.3
Affected Resource(s)
Please list the resources as a list, for example:
- postgresql_sequences
Terraform Configuration Files
data "postgresql_sequences" "db_sequences" {
database = "test"
}
Debug Output
I don't have one, please ask if you think it's needed. 🙏
Panic Output
None, terraform/terragrunt completes successfully
Expected Behavior
I'm using identity columns for some tables in my PostgreSQL database. The postgresql_sequences data source does not show them
terraform console
> data.postgresql_sequences.db_sequences
{
"database" = "test"
"id" = "test_ANY (array[])_ANY (array[])_ALL (array[])_ALL (array[])_"
"like_all_patterns" = tolist(null) /* of string */
"like_any_patterns" = tolist(null) /* of string */
"not_like_all_patterns" = tolist(null) /* of string */
"regex_pattern" = tostring(null)
"schemas" = tolist(null) /* of string */
"sequences" = tolist([])
}
data.postgresql_sequences.db_sequences.sequences is an empty list [], while in psql, \ds shows the identity column sequences (also, I'm able to grant privileges on them, so it makes sense to output them).
psql
xtz=> \ds
Liste des relations
Schéma | Nom | Type | Propriétaire
--------+----------------------------------+----------+--------------------
public | test_id_seq | séquence | test
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
- Create a table with an identity column
CREATE TABLE IF NOT EXISTS test (
id integer generated by default as identity,
value TEXT,
);
Important Factoids
My database is running on AWS RDS Aurora, but I don't think this changes much.
References
None that i'm aware of
Other notes
The column identity sequences don't appear in select * from information_schema.sequences;, but one can fetch from the column database by asking for colums which have is_identity set to YES. Then, the sequence name can be found with pg_get_serial_sequence:
select pg_get_serial_sequence(table_name, column_name) from information_schema.columns where is_identity = 'YES';
pg_get_serial_sequence
-----------------------------------------
public.test_id_seq
Credits: https://dba.stackexchange.com/questions/187708/how-to-get-information-about-the-sequence-behind-the-new-identity-column-in-post