Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 304cf15

Browse files
committed
Merge branch 'fix-db-schema' of github.com:siggi-k/yii2-openapi into fix-db-schema
2 parents 7754878 + 5870b24 commit 304cf15

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,35 +248,35 @@ $this->update('{{%company}}', ['name' => 'No name']);
248248
$this->alterColumn('{{%company}}', 'name', $this->string(128)->notNull());
249249
```
250250

251-
### Handling of `NOT NULL` constraints (#required, #nullable)
251+
### Handling of `NOT NULL` constraints
252252

253+
`NOT NULL` in DB migrations is determined by `nullable` and `required` properties of the OpenAPI schema.
253254
e.g. attribute = 'my_property'.
254255

255-
1) If you define attribute neither "required" nor via "nullable", then it is by default:
256-
ALLOW 'NOT NULL'
257-
```yaml
258-
test_table:
259-
required:
256+
- If you define attribute neither "required" nor via "nullable", then it is by default `NULL`:
257+
258+
```yaml
259+
ExampleSchema:
260260
properties:
261261
my_property:
262262
type: string
263263
```
264264
265-
2) If you define attribute by "required", then it is:
266-
FORBIDDEN 'NOT NULL'
267-
```yaml
268-
test_table:
265+
- If you define attribute in "required", then it is `NOT NULL`
266+
267+
```yaml
268+
ExampleSchema:
269269
required:
270270
- my_property
271271
properties:
272272
my_property:
273273
type: string
274274
```
275275

276-
3) If you define attribute via "nullable", then it has the highest priority.
277-
ALLOW 'NOT NULL'
278-
```yaml
279-
test_table:
276+
- If you define attribute via "nullable", then it overrides "required", e.g. allow `NULL` in this case:
277+
278+
```yaml
279+
ExampleSchema:
280280
required:
281281
- my_property
282282
properties:
@@ -285,8 +285,9 @@ e.g. attribute = 'my_property'.
285285
nullable: true
286286
```
287287

288-
FORBIDDEN 'NOT NULL'
289-
```yaml
288+
- If you define attribute via "nullable", then it overrides "required", e.g. `NOT NULL` in this case:
289+
290+
```yaml
290291
test_table:
291292
required:
292293
properties:

0 commit comments

Comments
 (0)