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

@@ -1034,6 +1034,12 @@ func (Card) Edges() []ent.Edge {
If the example above, a card entity cannot be created without its owner.
:::info
Note that, starting with [v0.10](https://github.com/ent/ent/releases/tag/v0.10.0), foreign key columns are created
as `NOT NULL` in the database for required edges that are not [self-reference](#o2m-same-type). In order to migrate
existing foreign key columns, use the [Atlas Migration](migrate.md#atlas-integration) option.
:::
## StorageKey
By default, Ent configures edge storage-keys by the edge-owner (the schema that holds the `edge.To`), and not the by