Commit Graph

84 Commits

Author SHA1 Message Date
adlerhurst
866c2971f1 enum 2025-08-07 10:52:57 +02:00
adlerhurst
aeff5928b8 correct db tag 2025-07-30 08:00:16 +02:00
adlerhurst
eaca713581 fixes 2025-07-30 07:58:27 +02:00
adlerhurst
9c9f3510aa cleanup 2025-07-29 00:33:02 +02:00
adlerhurst
e5ab582ff9 hope this works 2025-07-28 23:59:18 +02:00
adlerhurst
7820e43e7a set updated_at if nothing provided 2025-07-28 22:42:14 +02:00
adlerhurst
cebcec6f04 updated at 2025-07-28 17:13:00 +02:00
adlerhurst
32eccafbe8 tests 2025-07-28 16:16:13 +02:00
adlerhurst
1b9f83915c add trusted domain test cases 2025-07-28 11:07:41 +02:00
adlerhurst
60407ed261 add trusted domain test cases 2025-07-28 11:05:51 +02:00
adlerhurst
31916564db trusted domain event test 2025-07-28 10:50:17 +02:00
adlerhurst
ce60693c24 instance custom domain event tests done 2025-07-28 09:10:33 +02:00
adlerhurst
c7718aca8f fix event tests 2025-07-27 08:56:55 +02:00
adlerhurst
5aa1553a38 linting 2025-07-25 20:16:08 +02:00
adlerhurst
889420f2d8 linting 2025-07-25 20:05:15 +02:00
adlerhurst
1054a4bd53 cleanup 2025-07-25 17:59:02 +02:00
adlerhurst
24ef46e75b cleanup 2025-07-25 17:54:10 +02:00
adlerhurst
9d5f545623 allow setting updated at for backwards compatibility 2025-07-25 16:17:36 +02:00
adlerhurst
e7b0ca8ba9 add missing fields 2025-07-25 16:17:14 +02:00
adlerhurst
3aa5adf8f4 remove unused files 2025-07-25 16:16:57 +02:00
adlerhurst
5d309bcf5b feat(database): implement sql adapter for backwards compatibility 2025-07-25 16:16:45 +02:00
adlerhurst
d9bff64699 org domain tests 2025-07-23 12:11:51 +02:00
adlerhurst
e516c1cdf6 instance domain tests 2025-07-23 11:37:55 +02:00
adlerhurst
ca3dbd4d9d linting 2025-07-23 09:47:04 +02:00
adlerhurst
ef0722e352 Merge branch 'clean-transactional-propsal' into rt-domains 2025-07-22 19:14:06 +02:00
adlerhurst
9c348c0429 implementation done 2025-07-22 19:09:56 +02:00
Silvan
7708fdbbf4 chore(database): enhance error handling (#10279)
This PR enhances error handling in the database package by introducing
custom error types that wrap dialect-specific errors, providing better
abstraction and context for error handling across the application.

* Introduces standardized custom error types for common database errors
(no rows found, integrity violations, etc.)
* Wraps all PostgreSQL-specific errors at the dialect layer to provide
consistent error handling

# Which Problems Are Solved

The database package didn't wrap the errors from dialect specifc
packages.

# How the Problems Are Solved

Custom errors were added which wrap the dialect specifc errors.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-17 15:20:02 +01:00
adlerhurst
bb2d0aff3f get / list implemented 2025-07-17 15:32:50 +02:00
adlerhurst
65cd4ec668 state 2025-07-17 09:42:29 +02:00
adlerhurst
eef059d671 Merge branch 'error-handling' into rt-domains 2025-07-17 09:38:51 +02:00
adlerhurst
2234d6ec82 linting 2025-07-17 09:14:17 +02:00
adlerhurst
15d07c076f linting 2025-07-17 09:08:33 +02:00
adlerhurst
821b293025 fix error 2025-07-17 08:57:45 +02:00
Silvan
f0e6743220 Update backend/v3/storage/database/dialect/postgres/error.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-17 01:06:21 +02:00
adlerhurst
2ad7a16e4f add original error 2025-07-17 01:04:52 +02:00
adlerhurst
15a7810581 fix missed query row 2025-07-17 01:03:04 +02:00
adlerhurst
8bda1e098a org 2025-07-17 00:58:02 +02:00
adlerhurst
f8934b0c88 chore: wrap errors to custom errors 2025-07-17 00:54:21 +02:00
adlerhurst
a0329bd221 sql 2025-07-16 18:36:21 +02:00
adlerhurst
d63fe8e227 Merge branch 'clean-transactional-propsal' into rt-domains 2025-07-16 09:28:57 +02:00
adlerhurst
483b4daba4 domain is defined 2025-07-16 09:26:46 +02:00
Iraq
75a04e83ae chore(db): refactoring instance+org tables to not use deleted_at (#10270) 2025-07-15 20:20:53 +02:00
Iraq
8d020e56bb feat(db): adding org table to relational model (#10066)
# Which Problems Are Solved

As an outcome of [this
issue](https://github.com/zitadel/zitadel/issues/9599) we want to
implement relational tables in Zitadel. For that we use new tables as a
successor of the current tables used by Zitadel in `projections`, `auth`
and `admin` schemas. The new logic is based on [this
proposal](https://github.com/zitadel/zitadel/pull/9870). This issue does
not contain the switch from CQRS to the new tables. This is change will
be implemented in a later stage.

We focus on the most critical tables which is user authentication.

We need a table to manage organizations. 

### organization fields

The following fields must be managed in this table:

- `id`
- `instance_id`
- `name`
- `state` enum (active, inactive)
- `created_at`
- `updated_at`
- `deleted_at`

DISCUSS: should we add a `primary_domain` to this table so that we do
not have to join on domains to return a simple org?

We must ensure the unique constraints for this table matches the current
commands.

### organization repository

The repository must provide the following functions:

Manipulations:
- create
  - `instance_id`
  - `name`
- update
  - `name`
- delete

Queries:
- get returns single organization matching the criteria and pagination,
should return error if multiple were found
- list returns list of organizations matching the criteria, pagination

Criteria are the following:
- by id
- by name

pagination:
- by created_at
- by updated_at
- by name

### organization events

The following events must be applied on the table using a projection
(`internal/query/projection`)

- `org.added` results in create
- `org.changed` sets the `name` field
- `org.deactivated` sets the `state` field
- `org.reactivated` sets the `state` field
- `org.removed` sets the `deleted_at` field
- if answer is yes to discussion: `org.domain.primary.set` sets the
`primary_domain` field
- `instance.removed` sets the the `deleted_at` field if not already set

### acceptance criteria

- [x] migration is implemented and gets executed
- [x] domain interfaces are implemented and documented for service layer
- [x] repository is implemented and implements domain interface
- [x] testing
  - [x] the repository methods
  - [x] events get reduced correctly
  - [x] unique constraints
# Additional Context

Replace this example with links to related issues, discussions, discord
threads, or other sources with more context.
Use the Closing #issue syntax for issues that are resolved with this PR.
- Closes #https://github.com/zitadel/zitadel/issues/9936

---------

Co-authored-by: adlerhurst <27845747+adlerhurst@users.noreply.github.com>
2025-07-14 21:27:14 +02:00
Iraq
9595a1bcca feat(db): adding relational instance table (#10007)
<!--
Please inform yourself about the contribution guidelines on submitting a
PR here:
https://github.com/zitadel/zitadel/blob/main/CONTRIBUTING.md#submit-a-pull-request-pr.
Take note of how PR/commit titles should be written and replace the
template texts in the sections below. Don't remove any of the sections.
It is important that the commit history clearly shows what is changed
and why.
Important: By submitting a contribution you agree to the terms from our
Licensing Policy as described here:
https://github.com/zitadel/zitadel/blob/main/LICENSING.md#community-contributions.
-->

# Which Problems Are Solved

Implementing Instance table to new relational database schema

# How the Problems Are Solved


The following fields must be managed in this table:

- `id`
- `name`
- `default_org_id`
- `zitadel_project_id`
- `console_client_id`
- `console_app_id`
- `default_language`
- `created_at`
- `updated_at`
- `deleted_at`

The repository must provide the following functions:

Manipulations:
- create
  - `name`
  - `default_org_id`
  - `zitadel_project_id`
  - `console_client_id`
  - `console_app_id`
  - `default_language`
- update
  - `name`
  - `default_language`
- delete

Queries:
- get returns single instance matching the criteria and pagination,
should return error if multiple instances were found
- list returns list of instances matching the criteria, pagination

Criteria are the following:
- by id

pagination:
- by created_at
- by updated_at
- by name

### instance events

The following events must be applied on the table using a projection
(`internal/query/projection`)

- `instance.added` results in create
- `instance.changed` changes the `name` field
- `instance.removed` sets the the `deleted_at` field
- `instance.default.org.set` sets the `default_org_id` field
- `instance.iam.project.set` sets the `zitadel_project_id` field
- `instance.iam.console.set` sets the `console_client_id` and
`console_app_id` fields
- `instance.default.language.set` sets the `default_language` field
- if answer is yes to discussion: `instance.domain.primary.set` sets the
`primary_domain` field

### acceptance criteria

- [x] migration is implemented and gets executed
- [x] domain interfaces are implemented and documented for service layer
- [x] repository is implemented and implements domain interface
- [x] testing
  - [x] the repository methods
  - [x] events get reduced correctly
  - [x] unique constraints

# Additional Context

- Closes https://github.com/zitadel/zitadel/issues/9935
2025-06-17 09:46:01 +02:00
Iraq
d75a45ebed chore(linting): changes to make clean-transactional-propsal_lint pass… (#10072) 2025-06-13 16:05:37 +01:00
Silvan
01180d2a63 feat: add embedded testing server for postgres (#9955)
# Which Problems Are Solved

1. there was no embedded database to run tests against
2. there were no tests for postgres/migrate
3. there was no test setup for repository which starts a client for the
embedded database

# How the Problems Are Solved

1. postgres/embedded package was added
2. tests were added
3. TestMain was added incl. an example test

# Additional Changes

none

# Additional Context

closes #9934

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-26 09:31:45 +02:00
Silvan
362420f62b feat: init migrations for transactional tables (#9946)
# Which Problems Are Solved

To start with transactional tables we need to setup the new `zitadel`
schema in a way that does not rely on the event store later.

# How the Problems Are Solved

Setup step added which calls the function which executes the migrations.

# Additional Changes

none

# Additional Context

- closes #9933
2025-05-26 08:20:14 +02:00
adlerhurst
3ddecca600 remove unused tests 2025-05-09 07:16:18 +02:00
adlerhurst
66cbc5d181 doc 2025-05-08 19:03:14 +02:00
adlerhurst
c6db6dc4b7 add documentation 2025-05-08 19:01:55 +02:00