mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
feat: projections auto create their tables (#3324)
* begin init checks for projections * first projection checks * debug notification providers with query fixes * more projections and first index * more projections * more projections * finish projections * fix tests (remove db name) * create tables in setup * fix logging / error handling * add tenant to views * rename tenant to instance_id * add instance_id to all projections * add instance_id to all queries * correct instance_id on projections * add instance_id to failed_events * use separate context for instance * implement features projection * implement features projection * remove unique constraint from setup when migration failed * add error to failed setup event * add instance_id to primary keys * fix IAM projection * remove old migrations folder * fix keysFromYAML test
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package projection
|
||||
|
||||
import (
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore"
|
||||
"github.com/caos/zitadel/internal/eventstore/handler"
|
||||
"github.com/caos/zitadel/internal/eventstore/handler/crdb"
|
||||
"github.com/caos/zitadel/internal/repository/member"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,6 +17,19 @@ const (
|
||||
MemberChangeDate = "change_date"
|
||||
MemberSequence = "sequence"
|
||||
MemberResourceOwner = "resource_owner"
|
||||
MemberInstanceID = "instance_id"
|
||||
)
|
||||
|
||||
var (
|
||||
memberColumns = []*crdb.Column{
|
||||
crdb.NewColumn(MemberCreationDate, crdb.ColumnTypeTimestamp),
|
||||
crdb.NewColumn(MemberChangeDate, crdb.ColumnTypeTimestamp),
|
||||
crdb.NewColumn(MemberUserIDCol, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(MemberRolesCol, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
crdb.NewColumn(MemberSequence, crdb.ColumnTypeInt64),
|
||||
crdb.NewColumn(MemberResourceOwner, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(MemberInstanceID, crdb.ColumnTypeText),
|
||||
}
|
||||
)
|
||||
|
||||
type reduceMemberConfig struct {
|
||||
@@ -48,6 +62,7 @@ func reduceMemberAdded(e member.MemberAddedEvent, opts ...reduceMemberOpt) (*han
|
||||
handler.NewCol(MemberChangeDate, e.CreationDate()),
|
||||
handler.NewCol(MemberSequence, e.Sequence()),
|
||||
handler.NewCol(MemberResourceOwner, e.Aggregate().ResourceOwner),
|
||||
handler.NewCol(MemberInstanceID, e.Aggregate().InstanceID),
|
||||
}}
|
||||
|
||||
for _, opt := range opts {
|
||||
|
Reference in New Issue
Block a user