Skip to content

Commit

Permalink
add missing unique constraint and fix duplicate index on links
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Dec 26, 2023
1 parent 19f2f9a commit 614e112
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
5 changes: 3 additions & 2 deletions app/resources/link/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (d *database) Store(ctx context.Context, address, title, description string

slug, domain := getLinkAttrs(*u)

create := d.db.Link.Create()
create := d.db.Debug().Link.Create()
mutate := create.Mutation()

mutate.SetURL(address)
Expand All @@ -45,7 +45,8 @@ func (d *database) Store(ctx context.Context, address, title, description string
fn(mutate)
}

create.OnConflictColumns("url", "slug").UpdateNewValues()
create.OnConflictColumns("url").UpdateNewValues()
create.OnConflictColumns("slug").UpdateNewValues()

r, err := create.Save(ctx)
if err != nil {
Expand Down
12 changes: 0 additions & 12 deletions internal/ent/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions internal/ent/schema/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)

type Link struct {
Expand All @@ -29,13 +28,6 @@ func (Link) Fields() []ent.Field {
}
}

func (Link) Indexes() []ent.Index {
return []ent.Index{
index.Fields("url"),
index.Fields("slug"),
}
}

func (Link) Edges() []ent.Edge {
return []ent.Edge{
edge.To("posts", Post.Type),
Expand Down

1 comment on commit 614e112

@vercel
Copy link

@vercel vercel bot commented on 614e112 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.