mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 13:06:03 +08:00
chore: review comments
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
parent
3caaa51e08
commit
11d75940e8
@ -2,8 +2,6 @@ package sqlmigration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/SigNoz/signoz/pkg/factory"
|
"github.com/SigNoz/signoz/pkg/factory"
|
||||||
"github.com/SigNoz/signoz/pkg/sqlstore"
|
"github.com/SigNoz/signoz/pkg/sqlstore"
|
||||||
"github.com/SigNoz/signoz/pkg/types"
|
"github.com/SigNoz/signoz/pkg/types"
|
||||||
@ -12,8 +10,8 @@ import (
|
|||||||
"github.com/uptrace/bun/migrate"
|
"github.com/uptrace/bun/migrate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Funnel Core Data Structure (Funnel and FunnelStep)
|
// funnel Core Data Structure (funnel and funnelStep)
|
||||||
type Funnel struct {
|
type funnel struct {
|
||||||
bun.BaseModel `bun:"table:trace_funnel"`
|
bun.BaseModel `bun:"table:trace_funnel"`
|
||||||
types.Identifiable // funnel id
|
types.Identifiable // funnel id
|
||||||
types.TimeAuditable
|
types.TimeAuditable
|
||||||
@ -21,12 +19,12 @@ type Funnel struct {
|
|||||||
Name string `json:"funnel_name" bun:"name,type:text,notnull"` // funnel name
|
Name string `json:"funnel_name" bun:"name,type:text,notnull"` // funnel name
|
||||||
Description string `json:"description" bun:"description,type:text"` // funnel description
|
Description string `json:"description" bun:"description,type:text"` // funnel description
|
||||||
OrgID valuer.UUID `json:"org_id" bun:"org_id,type:varchar,notnull"`
|
OrgID valuer.UUID `json:"org_id" bun:"org_id,type:varchar,notnull"`
|
||||||
Steps []FunnelStep `json:"steps" bun:"steps,type:text,notnull"`
|
Steps []funnelStep `json:"steps" bun:"steps,type:text,notnull"`
|
||||||
Tags string `json:"tags" bun:"tags,type:text"`
|
Tags string `json:"tags" bun:"tags,type:text"`
|
||||||
CreatedByUser *types.User `json:"user" bun:"rel:belongs-to,join:created_by=id"`
|
CreatedByUser *types.User `json:"user" bun:"rel:belongs-to,join:created_by=id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FunnelStep struct {
|
type funnelStep struct {
|
||||||
types.Identifiable
|
types.Identifiable
|
||||||
Name string `json:"name,omitempty"` // step name
|
Name string `json:"name,omitempty"` // step name
|
||||||
Description string `json:"description,omitempty"` // step description
|
Description string `json:"description,omitempty"` // step description
|
||||||
@ -65,15 +63,17 @@ func (migration *addTraceFunnels) Up(ctx context.Context, db *bun.DB) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer func() {
|
||||||
|
_ = tx.Rollback()
|
||||||
|
}()
|
||||||
|
|
||||||
_, err = tx.NewCreateTable().
|
_, err = tx.NewCreateTable().
|
||||||
Model(new(Funnel)).
|
Model(new(funnel)).
|
||||||
ForeignKey(`("org_id") REFERENCES "organizations" ("id") ON DELETE CASCADE`).
|
ForeignKey(`("org_id") REFERENCES "organizations" ("id") ON DELETE CASCADE`).
|
||||||
IfNotExists().
|
IfNotExists().
|
||||||
Exec(ctx)
|
Exec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create trace_funnel table: %v", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Commit()
|
err = tx.Commit()
|
Loading…
x
Reference in New Issue
Block a user