Skip to content

Commit ae7bbfb

Browse files
committed
Change lot of tests
1 parent 918f5bf commit ae7bbfb

File tree

52 files changed

+234
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+234
-198
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ created_at:
236236
x-db-default-expression: current_timestamp()
237237
```
238238

239-
Note: If both `default` and `x-db-default-expression` are present then `default` will be considered.
239+
Note: If both `default` and `x-db-default-expression` are present, then `default` will be considered.
240240

241241
```yaml
242242
created_at:
@@ -600,7 +600,7 @@ User:
600600
`NOT NULL` in DB migrations is determined by `nullable` and `required` properties of the OpenAPI schema.
601601
e.g. attribute = 'my_property'.
602602
603-
- If you define attribute neither "required" nor via "nullable", then it is by default `NULL` ([opposite of OpenAPI spec](https://swagger.io/specification/v3/?sbsearch=nullable)):
603+
- If you define attribute neither "required" nor via "nullable", then it is by default `NOT NULL` ([as per OpenAPI spec](https://github.com/OAI/OpenAPI-Specification/blob/main/proposals/2019-10-31-Clarify-Nullable.md)):
604604
605605
```yaml
606606
ExampleSchema:

tests/specs/blog/migrations/m200000_000001_create_table_users.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public function up()
1212
'username' => $this->string(200)->notNull(),
1313
'email' => $this->string(200)->notNull(),
1414
'password' => $this->string()->notNull(),
15-
'role' => $this->string(20)->null()->defaultValue('reader'),
16-
'flags' => $this->integer()->null()->defaultValue(0),
17-
'created_at' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
15+
'role' => $this->string(20)->notNull()->defaultValue('reader'),
16+
'flags' => $this->integer()->notNull()->defaultValue(0),
17+
'created_at' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
1818
]);
1919
$this->createIndex('users_username_key', '{{%users}}', 'username', true);
2020
$this->createIndex('users_email_key', '{{%users}}', 'email', true);

tests/specs/blog/migrations/m200000_000002_create_table_blog_posts.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public function up()
1010
$this->createTable('{{%blog_posts}}', [
1111
0 => 'uid varchar(128) NOT NULL',
1212
'title' => $this->string(255)->notNull(),
13-
'slug' => $this->string(200)->null()->defaultValue(null),
13+
'slug' => $this->string(200)->notNull(),
1414
'category_id' => $this->integer()->notNull()->comment('Category of posts'),
1515
'active' => $this->boolean()->notNull()->defaultValue(false),
16-
'created_at' => $this->date()->null()->defaultValue(null),
17-
'created_by_id' => $this->integer()->null()->defaultValue(null)->comment('The User'),
16+
'created_at' => $this->date()->notNull(),
17+
'created_by_id' => $this->integer()->notNull()->comment('The User'),
1818
]);
1919
$this->addPrimaryKey('pk_blog_posts_uid', '{{%blog_posts}}', 'uid');
2020
$this->createIndex('blog_posts_title_key', '{{%blog_posts}}', 'title', true);

tests/specs/blog/migrations/m200000_000003_create_table_fakerable.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ public function up()
99
{
1010
$this->createTable('{{%fakerable}}', [
1111
'id' => $this->bigPrimaryKey(),
12-
'active' => $this->boolean()->null()->defaultValue(null),
13-
'floatval' => $this->float()->null()->defaultValue(null),
14-
'floatval_lim' => $this->float()->null()->defaultValue(null),
15-
'doubleval' => $this->double()->null()->defaultValue(null),
16-
'int_min' => $this->integer()->null()->defaultValue(3),
17-
'int_max' => $this->integer()->null()->defaultValue(null),
18-
'int_minmax' => $this->integer()->null()->defaultValue(null),
19-
'int_created_at' => $this->integer()->null()->defaultValue(null),
20-
'int_simple' => $this->integer()->null()->defaultValue(null),
21-
'str_text' => $this->text()->null(),
22-
'str_varchar' => $this->string(100)->null()->defaultValue(null),
23-
'str_date' => $this->date()->null()->defaultValue(null),
24-
'str_datetime' => $this->timestamp()->null()->defaultValue(null),
25-
'str_country' => $this->text()->null(),
12+
'active' => $this->boolean()->notNull(),
13+
'floatval' => $this->float()->notNull(),
14+
'floatval_lim' => $this->float()->notNull(),
15+
'doubleval' => $this->double()->notNull(),
16+
'int_min' => $this->integer()->notNull()->defaultValue(3),
17+
'int_max' => $this->integer()->notNull(),
18+
'int_minmax' => $this->integer()->notNull(),
19+
'int_created_at' => $this->integer()->notNull(),
20+
'int_simple' => $this->integer()->notNull(),
21+
'str_text' => $this->text()->notNull(),
22+
'str_varchar' => $this->string(100)->notNull(),
23+
'str_date' => $this->date()->notNull(),
24+
'str_datetime' => $this->timestamp()->notNull(),
25+
'str_country' => $this->text()->notNull(),
2626
]);
2727
}
2828

tests/specs/enum/change/maria/app/migrations_maria_db/m200000_000000_change_table_editcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class m200000_000000_change_table_editcolumns extends \yii\db\Migration
77
{
88
public function up()
99
{
10-
$this->alterColumn('{{%editcolumns}}', 'device', $this->text()->null()->defaultValue(null));
10+
$this->alterColumn('{{%editcolumns}}', 'device', $this->text()->notNull());
1111
$this->alterColumn('{{%editcolumns}}', 'connection', 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'');
1212
$this->alterColumn('{{%editcolumns}}', 'camelCaseCol', 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'');
1313
}

tests/specs/enum/change/mysql/app/migrations_mysql_db/m200000_000000_change_table_editcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class m200000_000000_change_table_editcolumns extends \yii\db\Migration
77
{
88
public function up()
99
{
10-
$this->alterColumn('{{%editcolumns}}', 'device', $this->text()->null());
10+
$this->alterColumn('{{%editcolumns}}', 'device', $this->text()->notNull());
1111
$this->alterColumn('{{%editcolumns}}', 'connection', 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'');
1212
$this->alterColumn('{{%editcolumns}}', 'camelCaseCol', 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'');
1313
}

tests/specs/enum/change/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_editcolumns.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ public function safeUp()
99
{
1010
$this->execute('CREATE TYPE "enum_itt_editcolumns_camelCaseCol" AS ENUM(\'ONE\', \'TWO\', \'THREE\')');
1111
$this->execute('CREATE TYPE "enum_itt_editcolumns_connection" AS ENUM(\'WIRED\', \'WIRELESS\')');
12-
$this->alterColumn('{{%editcolumns}}', 'device', 'text NULL USING "device"::text');
13-
$this->alterColumn('{{%editcolumns}}', 'device', "DROP NOT NULL");
12+
$this->alterColumn('{{%editcolumns}}', 'device', 'text NOT NULL USING "device"::text');
1413
$this->alterColumn('{{%editcolumns}}', 'device', "DROP DEFAULT");
1514
$this->execute('DROP TYPE "enum_itt_editcolumns_device"');
1615
$this->alterColumn('{{%editcolumns}}', 'connection', '"enum_itt_editcolumns_connection" USING "connection"::"enum_itt_editcolumns_connection"');
@@ -27,7 +26,6 @@ public function safeDown()
2726
$this->alterColumn('{{%editcolumns}}', 'connection', 'varchar(255) NULL USING "connection"::varchar');
2827
$this->execute('CREATE TYPE "enum_itt_editcolumns_device" AS ENUM(\'MOBILE\', \'TV\', \'COMPUTER\')');
2928
$this->alterColumn('{{%editcolumns}}', 'device', '"enum_itt_editcolumns_device" USING "device"::"enum_itt_editcolumns_device"');
30-
$this->alterColumn('{{%editcolumns}}', 'device', "SET NOT NULL");
3129
$this->alterColumn('{{%editcolumns}}', 'device', "SET DEFAULT 'TV'");
3230
$this->alterColumn('{{%editcolumns}}', 'connection', "DROP NOT NULL");
3331
$this->alterColumn('{{%editcolumns}}', 'connection', "DROP DEFAULT");

tests/specs/enum/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public function up()
99
{
1010
$this->createTable('{{%editcolumns}}', [
1111
'id' => $this->primaryKey(),
12-
'device' => $this->text()->null()->defaultValue(null),
12+
'device' => $this->text()->notNull(),
1313
'connection' => 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'',
1414
'camelCaseCol' => 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'',
1515
]);

tests/specs/enum/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public function up()
99
{
1010
$this->createTable('{{%editcolumns}}', [
1111
'id' => $this->primaryKey(),
12-
'device' => $this->text()->null(),
12+
'device' => $this->text()->notNull(),
1313
'connection' => 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'',
1414
'camelCaseCol' => 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'',
1515
]);

tests/specs/enum/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function safeUp()
1111
$this->execute('CREATE TYPE "enum_itt_editcolumns_connection" AS ENUM(\'WIRED\', \'WIRELESS\')');
1212
$this->createTable('{{%editcolumns}}', [
1313
'id' => $this->primaryKey(),
14-
'device' => $this->text()->null()->defaultValue(null),
14+
'device' => $this->text()->notNull(),
1515
'connection' => '"enum_itt_editcolumns_connection" NOT NULL DEFAULT \'WIRED\'',
1616
'camelCaseCol' => '"enum_itt_editcolumns_camelCaseCol" NOT NULL DEFAULT \'TWO\'',
1717
]);

0 commit comments

Comments
 (0)