Commit Graph

49 Commits

Author SHA1 Message Date
Iraq Jaber
9695de625f fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-11 12:12:59 +01:00
Iraq Jaber
ef96adf74c fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-11 10:58:37 +01:00
Iraq Jaber
2dc44031b6 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-11 10:15:55 +01:00
Iraq Jaber
a0ef9c0bd2 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-11 09:49:51 +01:00
Iraq Jaber
6fc9aa167b fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-08 11:34:09 +01:00
Iraq Jaber
5198c0e0a6 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-08 10:52:42 +01:00
Iraq Jaber
b522e691cc fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-08 10:22:53 +01:00
Iraq Jaber
aa281e1e2b fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-08 10:18:22 +01:00
Iraq Jaber
53811a1fd8 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-07 09:19:23 +01:00
Iraq Jaber
1c603ef30c fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-05 12:50:39 +01:00
Iraq Jaber
8fd3a0a4a8 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event
everything upto google done for org + instance
2025-08-05 10:01:49 +01:00
Iraq Jaber
5eb37f19cd fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-04 08:29:32 +01:00
Iraq Jaber
08c4fbe2de fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-01 14:51:36 +01:00
Iraq Jaber
63639769c4 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-08-01 09:53:42 +01:00
Iraq Jaber
1f4acc22e6 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-07-31 16:17:49 +01:00
Iraq Jaber
bd35df9856 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-07-31 15:36:52 +01:00
Iraq Jaber
4f4ae3e6ea fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-07-31 13:32:02 +01:00
Iraq Jaber
5ab959a6c1 fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-07-31 11:24:29 +01:00
Iraq Jaber
f12f31f6df fixup! fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-07-30 12:57:18 +01:00
Iraq Jaber
5ed2f54398 fixup! fixup! fixup! fixup! fixup! fixup! added first event 2025-07-30 12:15:56 +01:00
Iraq Jaber
ae65867849 fixup! fixup! fixup! fixup! fixup! added first event 2025-07-29 13:24:42 +01:00
Iraq Jaber
4f75d9b561 fixup! fixup! fixup! fixup! added first event 2025-07-28 09:24:47 +01:00
Iraq Jaber
5275e00f41 fixup! fixup! fixup! added first event 2025-07-25 17:06:18 +01:00
Iraq Jaber
a6a209c46a fixup! fixup! added first event 2025-07-25 12:14:28 +01:00
Iraq Jaber
666243cf27 fixup! added first event 2025-07-23 11:47:23 +01:00
Iraq Jaber
46958de19f added first event 2025-07-22 16:06:22 +01:00
Iraq Jaber
1b3abeea92 fixup! changed idp repo interface to use a pointer for orgID 2025-07-22 15:56:38 +01:00
Iraq Jaber
d5a228bb4b changed idp repo interface to use a pointer for orgID 2025-07-22 14:51:14 +01:00
Iraq Jaber
7fc6123e3f fixup! fixup! fixup! fixup! fixup! feat(db): Adding identity_providers table for relational database 2025-07-22 14:30:36 +01:00
Iraq Jaber
0809686c94 fixup! fixup! fixup! fixup! feat(db): Adding identity_providers table for relational database 2025-07-22 08:55:33 +01:00
Iraq Jaber
95f18433ef fixup! fixup! fixup! feat(db): Adding identity_providers table for relational database 2025-07-21 13:24:35 +01:00
Iraq Jaber
4638118e29 fixup! fixup! feat(db): Adding identity_providers table for relational database 2025-07-18 15:55:18 +01:00
Iraq Jaber
d951a8b13e fixup! feat(db): Adding identity_providers table for relational database 2025-07-18 11:02:50 +01:00
Iraq Jaber
9c94f2744a feat(db): Adding identity_providers table for relational database 2025-07-18 08:59:41 +01:00
Iraq Jaber
de0fd8d588 feat(db): Adding identity_providers table for relational database 2025-07-17 15:48:27 +01:00
Iraq Jaber
54654ecd55 db(identity_provider): adding identity_provider table to new relational model 2025-07-17 15:22:28 +01: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
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
c6db6dc4b7 add documentation 2025-05-08 19:01:55 +02:00
adlerhurst
47e63ed801 bla 2025-05-08 15:30:06 +02:00
adlerhurst
8ba497cb87 cleanup 2025-05-08 07:42:53 +02:00
adlerhurst
6ba86bc67b move files 2025-05-06 07:18:11 +02:00
adlerhurst
050aa7dd48 v4 without errors 2025-04-30 09:30:48 +02:00
adlerhurst
986c62b61a multiple tries 2025-04-29 06:03:47 +02:00