mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 01:18:51 +00:00
feat(relational): org metadata (#10761)
This pull request introduces a new feature that allows adding, updating, and querying metadata for organizations. The changes are primarily in the backend and include new database tables, repositories, and domain logic to support organization metadata. ## Changes * New `org_metadata` table: A new table `zitadel.org_metadata` is introduced to store metadata for organizations. It includes columns for `instance_id`, `org_id`, `key`, and `value`. The `value` is stored as a `BYTEA` type to allow for flexible data storage. * New `OrganizationMetadataRepository`: A new repository `OrganizationMetadataRepository` is created to handle all database operations for organization metadata. It provides methods to `Get`, `List`, `Set`, and `Remove` metadata. * New `org_metadata_relational_projection`: A new projection `org_metadata_relational_projection` is added to update the `zitadel.org_metadata` table based on events. It handles `MetadataSet`, `MetadataRemoved`, and `MetadataRemovedAll` events. * Updated `OrganizationRepository`: The `OrganizationRepository` is updated to support loading organization metadata. A new method `LoadMetadata` is added to enable joining the `org_metadata` table when querying for organizations. * Updated Organization domain: The Organization domain model is updated to include a new field `Metadata` of type `[]*OrganizationMetadata`. ## Additional Info * Extensible Design: The new metadata feature is designed to be extensible, allowing for future enhancements such as indexing on specific JSON fields within the `value` column. * closes https://github.com/zitadel/zitadel/issues/10206 * closes https://github.com/zitadel/zitadel/issues/10214
This commit is contained in:
@@ -23,7 +23,8 @@ type Organization struct {
|
||||
CreatedAt time.Time `json:"createdAt,omitzero" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitzero" db:"updated_at"`
|
||||
|
||||
Domains []*OrganizationDomain `json:"domains,omitempty" db:"-"` // domains need to be handled separately
|
||||
Domains []*OrganizationDomain `json:"domains,omitempty" db:"-"` // domains need to be handled separately
|
||||
Metadata []*OrganizationMetadata `json:"metadata,omitempty" db:"-"` // metadata need to be handled separately
|
||||
}
|
||||
|
||||
// organizationColumns define all the columns of the instance table.
|
||||
@@ -54,6 +55,8 @@ type organizationConditions interface {
|
||||
StateCondition(state OrgState) database.Condition
|
||||
// ExistsDomain returns a filter on the organizations domains.
|
||||
ExistsDomain(cond database.Condition) database.Condition
|
||||
// ExistsMetadata returns a filter on the organizations metadata.
|
||||
ExistsMetadata(cond database.Condition) database.Condition
|
||||
}
|
||||
|
||||
// organizationChanges define all the changes for the instance table.
|
||||
@@ -80,6 +83,9 @@ type OrganizationRepository interface {
|
||||
// LoadDomains loads the domains of the given organizations.
|
||||
// If it is called the [Organization].Domains field will be set on future calls to Get or List.
|
||||
LoadDomains() OrganizationRepository
|
||||
// LoadMetadata loads the metadata of the given organizations.
|
||||
// If it is called the [Organization].Metadata field will be set on future calls to Get or List.
|
||||
LoadMetadata() OrganizationRepository
|
||||
}
|
||||
|
||||
type CreateOrganization struct {
|
||||
|
||||
Reference in New Issue
Block a user