mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
058192c22b
* test: fix log headers * ensure just public types are tested * fix(postgres): proper statements for setup step 7 --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
37 lines
698 B
Go
37 lines
698 B
Go
package setup
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"embed"
|
|
)
|
|
|
|
var (
|
|
//go:embed 04/cockroach/index.sql
|
|
//go:embed 04/postgres/index.sql
|
|
stmts embed.FS
|
|
)
|
|
|
|
type EventstoreIndexes struct {
|
|
dbClient *sql.DB
|
|
dbType string
|
|
}
|
|
|
|
func (mig *EventstoreIndexes) Execute(ctx context.Context) error {
|
|
stmt, err := readStmt(stmts, "04", mig.dbType, "index.sql")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = mig.dbClient.ExecContext(ctx, stmt)
|
|
return err
|
|
}
|
|
|
|
func (mig *EventstoreIndexes) String() string {
|
|
return "04_eventstore_indexes"
|
|
}
|
|
|
|
func readStmt(fs embed.FS, folder, typ, filename string) (string, error) {
|
|
stmt, err := fs.ReadFile(folder + "/" + typ + "/" + filename)
|
|
return string(stmt), err
|
|
}
|