mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +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:
@@ -28,14 +28,14 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
` FROM projections.authn_keys`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -47,14 +47,14 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
` FROM projections.authn_keys`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -97,14 +97,14 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
` FROM projections.authn_keys`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -163,14 +163,14 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
` FROM projections.authn_keys`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -187,13 +187,13 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type`+
|
||||
` FROM projections.authn_keys`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -211,13 +211,13 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type`+
|
||||
` FROM projections.authn_keys`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -250,13 +250,13 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.id,`+
|
||||
` zitadel.projections.authn_keys.creation_date,`+
|
||||
` zitadel.projections.authn_keys.resource_owner,`+
|
||||
` zitadel.projections.authn_keys.sequence,`+
|
||||
` zitadel.projections.authn_keys.expiration,`+
|
||||
` zitadel.projections.authn_keys.type`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.id,`+
|
||||
` projections.authn_keys.creation_date,`+
|
||||
` projections.authn_keys.resource_owner,`+
|
||||
` projections.authn_keys.sequence,`+
|
||||
` projections.authn_keys.expiration,`+
|
||||
` projections.authn_keys.type`+
|
||||
` FROM projections.authn_keys`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -273,8 +273,8 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeyPublicKeyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.public_key`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.public_key`+
|
||||
` FROM projections.authn_keys`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -292,8 +292,8 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeyPublicKeyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.public_key`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.public_key`+
|
||||
` FROM projections.authn_keys`),
|
||||
[]string{
|
||||
"public_key",
|
||||
},
|
||||
@@ -309,8 +309,8 @@ func Test_AuthNKeyPrepares(t *testing.T) {
|
||||
prepare: prepareAuthNKeyPublicKeyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT zitadel.projections.authn_keys.public_key`+
|
||||
` FROM zitadel.projections.authn_keys`),
|
||||
regexp.QuoteMeta(`SELECT projections.authn_keys.public_key`+
|
||||
` FROM projections.authn_keys`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
Reference in New Issue
Block a user