entc/gen: set foreign-key columns non-nullable for required edges (#1703)

Note, this only applies to edges without circular references.
Fixed #1688 and #1374
This commit is contained in:
Ariel Mashraki
2022-01-23 22:23:37 +02:00
committed by GitHub
parent 1901cba436
commit 898991ac79
14 changed files with 84 additions and 55 deletions

View File

@@ -17,7 +17,7 @@ var (
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "expired", Type: field.TypeTime},
{Name: "number", Type: field.TypeString},
{Name: "user_card", Type: field.TypeInt, Unique: true, Nullable: true},
{Name: "user_card", Type: field.TypeInt, Unique: true},
}
// CardsTable holds the schema information for the "cards" table.
CardsTable = &schema.Table{
@@ -29,7 +29,7 @@ var (
Symbol: "cards_users_card",
Columns: []*schema.Column{CardsColumns[3]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
OnDelete: schema.NoAction,
},
},
}