Files
zitadel/cmd/setup
SilvanandGitHub 6d90a120a6 feat: allow transactional table setup step to recreate the whole schema (#11833)
## Problem description

- Setup currently creates/updates relational tables, but there is no
built-in way to fully reset the relational schema during iterative
development.
- Re-running setup after schema/projection changes can leave stale
relational objects and projection state behind, which makes local/dev
validation harder.
- There is no explicit, configurable switch in setup steps for
destructive schema recreation behavior.

## How the Problems Are Solved

- Adds a new setup step configuration section for relational tables with
a `ShouldRecreateSchema` flag (default `false`).
- Wires the new config flag into the transactional tables setup step.
- Extends the transactional tables execution logic to optionally:
  - Drop the `zitadel` schema with `CASCADE`
- Clean related projection state entries for relational tables in
`projections.current_states`
  - Recreate tables through the existing setup flow afterward
- Wraps the destructive operations in a transaction and keeps
error/rollback handling plus logging for visibility.

## Additional Changes

- Adds an explicit warning in step configuration that schema recreation
is intended for development and not production use.
- Keeps behavior fully backward-compatible by default
(`ShouldRecreateSchema: false`), so existing setups are unchanged unless
the flag is enabled.

## Additional Context

- Follow-up for relational setup/dev workflow improvements.
- PR: #11833

## How to use it

### Env `export ZITADEL_RELATIONALTABLES_SHOULDRECREATESCHEMA=true`

### Config

Add the following to your custom setup steps config:

```yaml
RelationalTables:
  ShouldRecreateSchema: true
```
2026-03-18 03:53:57 +00:00
..
2025-04-02 16:53:06 +02:00
2025-04-02 16:53:06 +02:00
2025-04-02 16:53:06 +02:00
2023-09-22 13:06:59 +02:00
2025-04-02 16:53:06 +02:00
2025-04-02 16:53:06 +02:00
2025-04-02 16:53:06 +02:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2026-02-25 06:33:28 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2025-04-02 16:53:06 +02:00
2025-04-02 16:53:06 +02:00
2026-02-04 11:51:43 +01:00
2024-01-25 17:28:20 +01:00
2024-01-25 17:28:20 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +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
2025-04-02 16:53:06 +02:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2024-10-28 08:29:34 +00:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2026-02-04 11:51:43 +01:00
2025-07-02 13:57:41 +02:00
2026-02-04 11:51:43 +01:00
2026-02-25 06:33:28 +01:00