This repository was archived by the owner on Jun 4, 2024. It is now read-only.
File tree 1 file changed +17
-16
lines changed 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -248,35 +248,35 @@ $this->update('{{%company}}', ['name' => 'No name']);
248
248
$this->alterColumn('{{%company}}', 'name', $this->string(128)->notNull());
249
249
```
250
250
251
- ### Handling of ` NOT NULL ` constraints (#required, #nullable)
251
+ ### Handling of ` NOT NULL ` constraints
252
252
253
+ ` NOT NULL ` in DB migrations is determined by ` nullable ` and ` required ` properties of the OpenAPI schema.
253
254
e.g. attribute = 'my_property'.
254
255
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 :
260
260
properties :
261
261
my_property :
262
262
type : string
263
263
` ` `
264
264
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 :
269
269
required:
270
270
- my_property
271
271
properties:
272
272
my_property:
273
273
type: string
274
274
` ` `
275
275
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 :
280
280
required:
281
281
- my_property
282
282
properties:
@@ -285,8 +285,9 @@ e.g. attribute = 'my_property'.
285
285
nullable: true
286
286
` ` `
287
287
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
290
291
test_table:
291
292
required:
292
293
properties:
You can’t perform that action at this time.
0 commit comments