Tim Möhlmann bcc6a689fa
fix(setup): use template for in_tx_order type (#9346)
# Which Problems Are Solved

Systems running with PostgreSQL before Zitadel v2.39 are likely to have
a wrong type for the `in_tx_order` column in the `eventstore.event2`
table. The migration at the time used the `event_sequence` as default
value without typecast, which results in a `bigint` type for that
column. However, when creating the table from scratch, we explicitly
specify the type to be `integer`.

Starting from Zitadel v2.67 we use a Pl/PgSQL function to push events.
The function requires the types from `eventstore.events2` to the same as
the `select` destinations used in the function. In the function
`in_tx_order` is also expected to by of `integer` type.

CochroachDB systems are not affected because `bigint` is an alias to the
`int` type. In other words, CockroachDB uses `int8` when specifying type
`int`. Therefore the types already match.

# How the Problems Are Solved

Retrieve the actual column type currently in use. A template is used to
assign the type to the `ordinality` column returned as `in_tx_order`.

# Additional Changes

- Detailed logging on migration failure

# Additional Context

- Closes #9180

---------

Co-authored-by: Silvan <27845747+adlerhurst@users.noreply.github.com>
2025-02-12 11:06:34 +00:00
..
2023-09-22 13:06:59 +02:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-11-28 10:06:52 +00:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2023-11-22 12:05:14 +00:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2023-12-08 13:14:22 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-01-17 10:16:48 +00:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2024-10-04 13:15:41 +00:00
2024-10-28 08:29:34 +00:00