entc/gen: allow setting unique fields with default values of type function (#610)

Fixed #609
This commit is contained in:
Ariel Mashraki
2020-07-16 18:57:08 +03:00
committed by GitHub
parent 9d42b5ef40
commit 4e9fd67a3e
3 changed files with 4 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ var (
// BlobsColumns holds the columns for the "blobs" table.
BlobsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "uuid", Type: field.TypeUUID},
{Name: "uuid", Type: field.TypeUUID, Unique: true},
{Name: "blob_parent", Type: field.TypeUUID, Unique: true, Nullable: true},
}
// BlobsTable holds the schema information for the "blobs" table.

View File

@@ -23,7 +23,8 @@ func (Blob) Fields() []ent.Field {
field.UUID("id", uuid.UUID{}).
Default(uuid.New),
field.UUID("uuid", uuid.UUID{}).
Default(uuid.New),
Default(uuid.New).
Unique(),
}
}