2022-03-23 09:02:39 +01:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
_ "embed"
|
2024-01-25 17:28:20 +01:00
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2022-03-23 09:02:39 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
//go:embed 01_sql/adminapi.sql
|
|
|
|
createAdminViews string
|
|
|
|
//go:embed 01_sql/auth.sql
|
|
|
|
createAuthViews string
|
|
|
|
//go:embed 01_sql/projections.sql
|
|
|
|
createProjections string
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectionTable struct {
|
|
|
|
dbClient *sql.DB
|
|
|
|
}
|
|
|
|
|
2024-01-25 17:28:20 +01:00
|
|
|
func (mig *ProjectionTable) Execute(ctx context.Context, _ eventstore.Event) error {
|
2022-08-31 09:52:43 +02:00
|
|
|
stmt := createAdminViews + createAuthViews + createProjections
|
2022-03-23 09:02:39 +01:00
|
|
|
_, err := mig.dbClient.ExecContext(ctx, stmt)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mig *ProjectionTable) String() string {
|
|
|
|
return "01_tables"
|
|
|
|
}
|