Skip to content

Commit

Permalink
fix(eventstore): new column to test clock_timestamp()
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerhurst committed May 11, 2023
1 parent 35a0977 commit c6d29fc
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/setup/10.go
Expand Up @@ -13,11 +13,11 @@ import (
)

var (
//go:embed 10_create_temp_table.sql
//go:embed 10/10_create_temp_table.sql
correctCreationDate10CreateTable string
//go:embed 10_fill_table.sql
//go:embed 10/10_fill_table.sql
correctCreationDate10FillTable string
//go:embed 10_update.sql
//go:embed 10/10_update.sql
correctCreationDate10Update string
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions cmd/setup/11.go
@@ -0,0 +1,26 @@
package setup

import (
"context"
_ "embed"

"github.com/zitadel/zitadel/internal/database"
)

var (
//go:embed 11.sql
addEventCreatedAt string
)

type AddEventCreatedAt struct {
dbClient *database.DB
}

func (mig *AddEventCreatedAt) Execute(ctx context.Context) error {
_, err := mig.dbClient.ExecContext(ctx, addEventCreatedAt)
return err
}

func (mig *AddEventCreatedAt) String() string {
return "11_event_created_at"
}
1 change: 1 addition & 0 deletions cmd/setup/11.sql
@@ -0,0 +1 @@
ALTER TABLE eventstore.events ADD COLUMN created_at TIMESTAMPTZ /*NOT NULL*/ DEFAULT clock_timestamp();
1 change: 1 addition & 0 deletions cmd/setup/config.go
Expand Up @@ -66,6 +66,7 @@ type Steps struct {
s8AuthTokens *AuthTokenIndexes
s9EventstoreIndexes2 *EventstoreIndexesNew
CorrectCreationDate *CorrectCreationDate
s11AddEventCreatedAt *AddEventCreatedAt
}

type encryptionKeyConfig struct {
Expand Down
3 changes: 3 additions & 0 deletions cmd/setup/setup.go
Expand Up @@ -91,6 +91,7 @@ func Setup(config *Config, steps *Steps, masterKey string) {
steps.s8AuthTokens = &AuthTokenIndexes{dbClient: dbClient}
steps.s9EventstoreIndexes2 = New09(dbClient)
steps.CorrectCreationDate.dbClient = dbClient
steps.s11AddEventCreatedAt = &AddEventCreatedAt{dbClient: dbClient}

err = projection.Create(ctx, dbClient, eventstoreClient, config.Projections, nil, nil)
logging.OnError(err).Fatal("unable to start projections")
Expand Down Expand Up @@ -128,6 +129,8 @@ func Setup(config *Config, steps *Steps, masterKey string) {
logging.OnError(err).Fatal("unable to migrate step 9")
err = migration.Migrate(ctx, eventstoreClient, steps.CorrectCreationDate)
logging.OnError(err).Fatal("unable to migrate step 10")
err = migration.Migrate(ctx, eventstoreClient, steps.s11AddEventCreatedAt)
logging.OnError(err).Fatal("unable to migrate step 11")

for _, repeatableStep := range repeatableSteps {
err = migration.Migrate(ctx, eventstoreClient, repeatableStep)
Expand Down

0 comments on commit c6d29fc

Please sign in to comment.