From 2e469a1c118408a2b06794dce6534756ad7bc6e7 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Mon, 10 Mar 2025 14:58:59 +0530
Subject: [PATCH 01/12] WIP

---
 src/lib/AttributeResolver.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lib/AttributeResolver.php b/src/lib/AttributeResolver.php
index cc41a6fb..29dcb113 100644
--- a/src/lib/AttributeResolver.php
+++ b/src/lib/AttributeResolver.php
@@ -211,7 +211,9 @@ protected function resolveProperty(
         $nullableValue = 'ARG_ABSENT'
     ): void {
         if ($nullableValue === 'ARG_ABSENT') {
-            $nullableValue = $property->getProperty()->getSerializableData()->nullable ?? null;
+//            $nullableValue = $property->getProperty()->getSerializableData()->nullable ?? null;
+//            $nullableValue = $property->getAttr('nullable') ?? null;
+            $nullableValue = $property->getProperty()->nullable ?? null;
         }
         $attribute = Yii::createObject(Attribute::class, [$property->getName()]);
 

From 7d0f71fb8548089e0d59cce4b92c43cba2c5843b Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Mon, 10 Mar 2025 15:21:42 +0530
Subject: [PATCH 02/12] WIP 2

---
 src/lib/AttributeResolver.php | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/lib/AttributeResolver.php b/src/lib/AttributeResolver.php
index 29dcb113..df912297 100644
--- a/src/lib/AttributeResolver.php
+++ b/src/lib/AttributeResolver.php
@@ -87,9 +87,12 @@ public function resolve(): DbModel
             /** @var $property PropertySchema */
 
             $isRequired = $this->componentSchema->isRequiredProperty($property->getName());
-            $nullableValue = $property->getProperty()->getSerializableData()->nullable ?? null;
-            if ($nullableValue === false) { // see docs in README regarding NOT NULL, required and nullable
-                $isRequired = true;
+            $nullableValue = false; # https://github.com/OAI/OpenAPI-Specification/blob/main/proposals/2019-10-31-Clarify-Nullable.md
+
+            if ($property->hasAttr('nullable')) {
+                if ($property->getAttr('nullable') === true) {
+                    $nullableValue = true;
+                }
             }
 
             if ($this->isJunctionSchema) {
@@ -211,9 +214,10 @@ protected function resolveProperty(
         $nullableValue = 'ARG_ABSENT'
     ): void {
         if ($nullableValue === 'ARG_ABSENT') {
-//            $nullableValue = $property->getProperty()->getSerializableData()->nullable ?? null;
-//            $nullableValue = $property->getAttr('nullable') ?? null;
-            $nullableValue = $property->getProperty()->nullable ?? null;
+            $nullableValue = false;
+            if ($property->hasAttr('nullable') && $property->getAttr('nullable') === true) {
+                $nullableValue = true;
+            }
         }
         $attribute = Yii::createObject(Attribute::class, [$property->getName()]);
 

From 918f5bf4bded7f59d7f1a1b0eb82c542b3b70227 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Mon, 10 Mar 2025 15:27:14 +0530
Subject: [PATCH 03/12] Handle nullable value

---
 src/lib/AttributeResolver.php | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/lib/AttributeResolver.php b/src/lib/AttributeResolver.php
index df912297..3c8ec5ad 100644
--- a/src/lib/AttributeResolver.php
+++ b/src/lib/AttributeResolver.php
@@ -87,13 +87,7 @@ public function resolve(): DbModel
             /** @var $property PropertySchema */
 
             $isRequired = $this->componentSchema->isRequiredProperty($property->getName());
-            $nullableValue = false; # https://github.com/OAI/OpenAPI-Specification/blob/main/proposals/2019-10-31-Clarify-Nullable.md
-
-            if ($property->hasAttr('nullable')) {
-                if ($property->getAttr('nullable') === true) {
-                    $nullableValue = true;
-                }
-            }
+            $nullableValue = $this->nullableValue($property);
 
             if ($this->isJunctionSchema) {
                 $this->resolveJunctionTableProperty($property, $isRequired);
@@ -214,10 +208,7 @@ protected function resolveProperty(
         $nullableValue = 'ARG_ABSENT'
     ): void {
         if ($nullableValue === 'ARG_ABSENT') {
-            $nullableValue = false;
-            if ($property->hasAttr('nullable') && $property->getAttr('nullable') === true) {
-                $nullableValue = true;
-            }
+            $nullableValue = $this->nullableValue($property);
         }
         $attribute = Yii::createObject(Attribute::class, [$property->getName()]);
 
@@ -542,4 +533,18 @@ public function addInverseRelation(
         $inverseRelation->setInverse($property->getName());
         $this->inverseRelations[$relatedClassName][] = $inverseRelation;
     }
+
+    /**
+     * Compute nullable value
+     */
+    private function nullableValue(PropertySchema $property): bool
+    {
+        $nullableValue = false; # https://github.com/OAI/OpenAPI-Specification/blob/main/proposals/2019-10-31-Clarify-Nullable.md
+
+        if ($property->hasAttr('nullable') && $property->getAttr('nullable') === true) {
+            $nullableValue = true;
+        }
+
+        return $nullableValue;
+    }
 }

From ae7bbfbedbaa18fe3752560d28a73556af51850b Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Mon, 10 Mar 2025 16:59:13 +0530
Subject: [PATCH 04/12] Change lot of tests

---
 README.md                                     |  4 +-
 .../m200000_000001_create_table_users.php     |  6 +--
 ...m200000_000002_create_table_blog_posts.php |  6 +--
 .../m200000_000003_create_table_fakerable.php | 28 +++++++-------
 ...200000_000000_change_table_editcolumns.php |  2 +-
 ...200000_000000_change_table_editcolumns.php |  2 +-
 ...200000_000000_change_table_editcolumns.php |  4 +-
 ...200000_000000_create_table_editcolumns.php |  2 +-
 ...200000_000000_create_table_editcolumns.php |  2 +-
 ...200000_000000_create_table_editcolumns.php |  2 +-
 ...200000_000000_create_table_editcolumns.php |  2 +-
 ...200000_000000_create_table_editcolumns.php |  2 +-
 ...200000_000000_create_table_editcolumns.php |  2 +-
 ...m200000_000000_create_table_deliveries.php |  2 +-
 .../m200000_000002_create_table_webhooks.php  |  6 +--
 ...m200000_000000_create_table_deliveries.php |  2 +-
 .../m200000_000002_create_table_webhooks.php  |  8 ++--
 .../m200000_000000_change_table_fruits.php    |  4 +-
 .../m200000_000000_change_table_fruits.php    |  4 +-
 .../m200000_000000_change_table_fruits.php    |  2 +-
 ...0000_000006_create_table_posts_gallery.php |  2 +-
 .../m200000_000000_create_table_menus.php     |  4 +-
 ...0_change_table_addtwonewcolinbetween2s.php |  6 +--
 ...01_change_table_addtwonewcolinbetweens.php |  6 +--
 .../m200000_000006_change_table_twocol2s.php  |  4 +-
 .../m200000_000007_change_table_twocols.php   |  4 +-
 ..._000008_change_table_twonewcolatlast2s.php |  4 +-
 ...0_000009_change_table_twonewcolatlasts.php |  4 +-
 ...0_change_table_addtwonewcolinbetween2s.php |  6 +--
 ...01_change_table_addtwonewcolinbetweens.php |  6 +--
 .../m200000_000006_change_table_twocol2s.php  |  4 +-
 .../m200000_000007_change_table_twocols.php   |  4 +-
 ..._000008_change_table_twonewcolatlast2s.php |  4 +-
 ...0_000009_change_table_twonewcolatlasts.php |  4 +-
 .../new_column_position.yaml                  |  1 -
 .../m200000_000000_create_table_pets.php      |  2 +-
 .../m200000_000000_create_table_pets.php      |  2 +-
 .../m200000_000000_change_table_fruits.php    | 22 +++++------
 .../m200000_000000_change_table_fruits.php    | 22 +++++------
 .../m200000_000000_create_table_fruits.php    | 20 +++++-----
 .../m200000_000000_change_table_fruits.php    | 18 ++++-----
 .../m200000_000000_change_table_fruits.php    | 18 ++++-----
 .../m200000_000000_create_table_fruits.php    | 20 +++++-----
 .../m200000_000000_change_table_fruits.php    | 18 +++++++++
 .../m200000_000000_change_table_fruits.php    | 18 +++++++++
 .../m200000_000000_create_table_fruits.php    | 20 +++++-----
 .../m200000_000000_create_table_userxes.php   |  2 +-
 .../m200000_000001_create_table_postxes.php   | 10 ++---
 tests/unit/Issue58FixTest.php                 |  9 +++--
 tests/unit/IssueFixTest.php                   | 34 ++++++++---------
 tests/unit/NewColumnPositionTest.php          | 38 +++++++++----------
 tests/unit/XDbDefaultExpressionTest.php       |  4 +-
 52 files changed, 234 insertions(+), 198 deletions(-)

diff --git a/README.md b/README.md
index f68df469..f7eadf30 100644
--- a/README.md
+++ b/README.md
@@ -236,7 +236,7 @@ created_at:
   x-db-default-expression: current_timestamp()
 ```
 
-Note: If both `default` and `x-db-default-expression` are present then `default` will be considered.
+Note: If both `default` and `x-db-default-expression` are present, then `default` will be considered.
 
 ```yaml
 created_at:
@@ -600,7 +600,7 @@ User:
 `NOT NULL` in DB migrations is determined by `nullable` and `required` properties of the OpenAPI schema.
 e.g. attribute = 'my_property'.
 
-- 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)):
+- 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)):
 
 ```yaml
   ExampleSchema:
diff --git a/tests/specs/blog/migrations/m200000_000001_create_table_users.php b/tests/specs/blog/migrations/m200000_000001_create_table_users.php
index a90792e9..813b1c95 100644
--- a/tests/specs/blog/migrations/m200000_000001_create_table_users.php
+++ b/tests/specs/blog/migrations/m200000_000001_create_table_users.php
@@ -12,9 +12,9 @@ public function up()
             'username' => $this->string(200)->notNull(),
             'email' => $this->string(200)->notNull(),
             'password' => $this->string()->notNull(),
-            'role' => $this->string(20)->null()->defaultValue('reader'),
-            'flags' => $this->integer()->null()->defaultValue(0),
-            'created_at' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'role' => $this->string(20)->notNull()->defaultValue('reader'),
+            'flags' => $this->integer()->notNull()->defaultValue(0),
+            'created_at' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
         ]);
         $this->createIndex('users_username_key', '{{%users}}', 'username', true);
         $this->createIndex('users_email_key', '{{%users}}', 'email', true);
diff --git a/tests/specs/blog/migrations/m200000_000002_create_table_blog_posts.php b/tests/specs/blog/migrations/m200000_000002_create_table_blog_posts.php
index c7cc90fb..acb248b0 100644
--- a/tests/specs/blog/migrations/m200000_000002_create_table_blog_posts.php
+++ b/tests/specs/blog/migrations/m200000_000002_create_table_blog_posts.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%blog_posts}}', [
             0 => 'uid varchar(128) NOT NULL',
             'title' => $this->string(255)->notNull(),
-            'slug' => $this->string(200)->null()->defaultValue(null),
+            'slug' => $this->string(200)->notNull(),
             'category_id' => $this->integer()->notNull()->comment('Category of posts'),
             'active' => $this->boolean()->notNull()->defaultValue(false),
-            'created_at' => $this->date()->null()->defaultValue(null),
-            'created_by_id' => $this->integer()->null()->defaultValue(null)->comment('The User'),
+            'created_at' => $this->date()->notNull(),
+            'created_by_id' => $this->integer()->notNull()->comment('The User'),
         ]);
         $this->addPrimaryKey('pk_blog_posts_uid', '{{%blog_posts}}', 'uid');
         $this->createIndex('blog_posts_title_key', '{{%blog_posts}}', 'title', true);
diff --git a/tests/specs/blog/migrations/m200000_000003_create_table_fakerable.php b/tests/specs/blog/migrations/m200000_000003_create_table_fakerable.php
index 0f3eebad..bd7b21f4 100644
--- a/tests/specs/blog/migrations/m200000_000003_create_table_fakerable.php
+++ b/tests/specs/blog/migrations/m200000_000003_create_table_fakerable.php
@@ -9,20 +9,20 @@ public function up()
     {
         $this->createTable('{{%fakerable}}', [
             'id' => $this->bigPrimaryKey(),
-            'active' => $this->boolean()->null()->defaultValue(null),
-            'floatval' => $this->float()->null()->defaultValue(null),
-            'floatval_lim' => $this->float()->null()->defaultValue(null),
-            'doubleval' => $this->double()->null()->defaultValue(null),
-            'int_min' => $this->integer()->null()->defaultValue(3),
-            'int_max' => $this->integer()->null()->defaultValue(null),
-            'int_minmax' => $this->integer()->null()->defaultValue(null),
-            'int_created_at' => $this->integer()->null()->defaultValue(null),
-            'int_simple' => $this->integer()->null()->defaultValue(null),
-            'str_text' => $this->text()->null(),
-            'str_varchar' => $this->string(100)->null()->defaultValue(null),
-            'str_date' => $this->date()->null()->defaultValue(null),
-            'str_datetime' => $this->timestamp()->null()->defaultValue(null),
-            'str_country' => $this->text()->null(),
+            'active' => $this->boolean()->notNull(),
+            'floatval' => $this->float()->notNull(),
+            'floatval_lim' => $this->float()->notNull(),
+            'doubleval' => $this->double()->notNull(),
+            'int_min' => $this->integer()->notNull()->defaultValue(3),
+            'int_max' => $this->integer()->notNull(),
+            'int_minmax' => $this->integer()->notNull(),
+            'int_created_at' => $this->integer()->notNull(),
+            'int_simple' => $this->integer()->notNull(),
+            'str_text' => $this->text()->notNull(),
+            'str_varchar' => $this->string(100)->notNull(),
+            'str_date' => $this->date()->notNull(),
+            'str_datetime' => $this->timestamp()->notNull(),
+            'str_country' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/enum/change/maria/app/migrations_maria_db/m200000_000000_change_table_editcolumns.php b/tests/specs/enum/change/maria/app/migrations_maria_db/m200000_000000_change_table_editcolumns.php
index 3df0a659..04e398b6 100644
--- a/tests/specs/enum/change/maria/app/migrations_maria_db/m200000_000000_change_table_editcolumns.php
+++ b/tests/specs/enum/change/maria/app/migrations_maria_db/m200000_000000_change_table_editcolumns.php
@@ -7,7 +7,7 @@ class m200000_000000_change_table_editcolumns extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%editcolumns}}', 'device', $this->text()->null()->defaultValue(null));
+        $this->alterColumn('{{%editcolumns}}', 'device', $this->text()->notNull());
         $this->alterColumn('{{%editcolumns}}', 'connection', 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'');
         $this->alterColumn('{{%editcolumns}}', 'camelCaseCol', 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'');
     }
diff --git a/tests/specs/enum/change/mysql/app/migrations_mysql_db/m200000_000000_change_table_editcolumns.php b/tests/specs/enum/change/mysql/app/migrations_mysql_db/m200000_000000_change_table_editcolumns.php
index 117d6069..04e398b6 100644
--- a/tests/specs/enum/change/mysql/app/migrations_mysql_db/m200000_000000_change_table_editcolumns.php
+++ b/tests/specs/enum/change/mysql/app/migrations_mysql_db/m200000_000000_change_table_editcolumns.php
@@ -7,7 +7,7 @@ class m200000_000000_change_table_editcolumns extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%editcolumns}}', 'device', $this->text()->null());
+        $this->alterColumn('{{%editcolumns}}', 'device', $this->text()->notNull());
         $this->alterColumn('{{%editcolumns}}', 'connection', 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'');
         $this->alterColumn('{{%editcolumns}}', 'camelCaseCol', 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'');
     }
diff --git a/tests/specs/enum/change/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_editcolumns.php b/tests/specs/enum/change/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_editcolumns.php
index 66287960..9019b576 100644
--- a/tests/specs/enum/change/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_editcolumns.php
+++ b/tests/specs/enum/change/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_editcolumns.php
@@ -9,8 +9,7 @@ public function safeUp()
     {
         $this->execute('CREATE TYPE "enum_itt_editcolumns_camelCaseCol" AS ENUM(\'ONE\', \'TWO\', \'THREE\')');
         $this->execute('CREATE TYPE "enum_itt_editcolumns_connection" AS ENUM(\'WIRED\', \'WIRELESS\')');
-        $this->alterColumn('{{%editcolumns}}', 'device', 'text NULL USING "device"::text');
-        $this->alterColumn('{{%editcolumns}}', 'device', "DROP NOT NULL");
+        $this->alterColumn('{{%editcolumns}}', 'device', 'text NOT NULL USING "device"::text');
         $this->alterColumn('{{%editcolumns}}', 'device', "DROP DEFAULT");
         $this->execute('DROP TYPE "enum_itt_editcolumns_device"');
         $this->alterColumn('{{%editcolumns}}', 'connection', '"enum_itt_editcolumns_connection" USING "connection"::"enum_itt_editcolumns_connection"');
@@ -27,7 +26,6 @@ public function safeDown()
         $this->alterColumn('{{%editcolumns}}', 'connection', 'varchar(255) NULL USING "connection"::varchar');
         $this->execute('CREATE TYPE "enum_itt_editcolumns_device" AS ENUM(\'MOBILE\', \'TV\', \'COMPUTER\')');
         $this->alterColumn('{{%editcolumns}}', 'device', '"enum_itt_editcolumns_device" USING "device"::"enum_itt_editcolumns_device"');
-        $this->alterColumn('{{%editcolumns}}', 'device', "SET NOT NULL");
         $this->alterColumn('{{%editcolumns}}', 'device', "SET DEFAULT 'TV'");
         $this->alterColumn('{{%editcolumns}}', 'connection', "DROP NOT NULL");
         $this->alterColumn('{{%editcolumns}}', 'connection', "DROP DEFAULT");
diff --git a/tests/specs/enum/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php b/tests/specs/enum/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php
index 1d2581bf..c7c8c233 100644
--- a/tests/specs/enum/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php
+++ b/tests/specs/enum/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
-            'device' => $this->text()->null()->defaultValue(null),
+            'device' => $this->text()->notNull(),
             'connection' => 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'',
             'camelCaseCol' => 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'',
         ]);
diff --git a/tests/specs/enum/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php b/tests/specs/enum/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php
index 3aeb5b25..c7c8c233 100644
--- a/tests/specs/enum/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php
+++ b/tests/specs/enum/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
-            'device' => $this->text()->null(),
+            'device' => $this->text()->notNull(),
             'connection' => 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'',
             'camelCaseCol' => 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'',
         ]);
diff --git a/tests/specs/enum/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php b/tests/specs/enum/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php
index 5180bf54..b37ca9a2 100644
--- a/tests/specs/enum/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php
+++ b/tests/specs/enum/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php
@@ -11,7 +11,7 @@ public function safeUp()
         $this->execute('CREATE TYPE "enum_itt_editcolumns_connection" AS ENUM(\'WIRED\', \'WIRELESS\')');
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
-            'device' => $this->text()->null()->defaultValue(null),
+            'device' => $this->text()->notNull(),
             'connection' => '"enum_itt_editcolumns_connection" NOT NULL DEFAULT \'WIRED\'',
             'camelCaseCol' => '"enum_itt_editcolumns_camelCaseCol" NOT NULL DEFAULT \'TWO\'',
         ]);
diff --git a/tests/specs/enum/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php b/tests/specs/enum/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php
index 1d2581bf..c7c8c233 100644
--- a/tests/specs/enum/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php
+++ b/tests/specs/enum/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_editcolumns.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
-            'device' => $this->text()->null()->defaultValue(null),
+            'device' => $this->text()->notNull(),
             'connection' => 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'',
             'camelCaseCol' => 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'',
         ]);
diff --git a/tests/specs/enum/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php b/tests/specs/enum/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php
index 3aeb5b25..c7c8c233 100644
--- a/tests/specs/enum/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php
+++ b/tests/specs/enum/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_editcolumns.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
-            'device' => $this->text()->null(),
+            'device' => $this->text()->notNull(),
             'connection' => 'enum("WIRED", "WIRELESS") NOT NULL DEFAULT \'WIRED\'',
             'camelCaseCol' => 'enum("ONE", "TWO", "THREE") NOT NULL DEFAULT \'TWO\'',
         ]);
diff --git a/tests/specs/enum/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php b/tests/specs/enum/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php
index 5180bf54..b37ca9a2 100644
--- a/tests/specs/enum/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php
+++ b/tests/specs/enum/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_editcolumns.php
@@ -11,7 +11,7 @@ public function safeUp()
         $this->execute('CREATE TYPE "enum_itt_editcolumns_connection" AS ENUM(\'WIRED\', \'WIRELESS\')');
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
-            'device' => $this->text()->null()->defaultValue(null),
+            'device' => $this->text()->notNull(),
             'connection' => '"enum_itt_editcolumns_connection" NOT NULL DEFAULT \'WIRED\'',
             'camelCaseCol' => '"enum_itt_editcolumns_camelCaseCol" NOT NULL DEFAULT \'TWO\'',
         ]);
diff --git a/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php b/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php
index e88d0ea9..bad5d1a0 100644
--- a/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php
+++ b/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%deliveries}}', [
             'id' => $this->primaryKey(),
-            'title' => $this->text()->null(),
+            'title' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php b/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php
index 5d3abaf3..88942f32 100644
--- a/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php
+++ b/tests/specs/fk_col_name/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php
@@ -9,9 +9,9 @@ public function up()
     {
         $this->createTable('{{%webhooks}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null(),
-            'user_id' => $this->integer()->null()->defaultValue(null)->comment('Test model for model code generation that should not contain id column in rules'),
-            'redelivery_of' => $this->integer()->null()->defaultValue(null),
+            'name' => $this->text()->notNull(),
+            'user_id' => $this->integer()->notNull()->comment('Test model for model code generation that should not contain id column in rules'),
+            'redelivery_of' => $this->integer()->notNull(),
         ]);
         $this->addForeignKey('fk_webhooks_user_id_users_id', '{{%webhooks}}', 'user_id', '{{%users}}', 'id');
         $this->addForeignKey('fk_webhooks_redelivery_of_deliveries_id', '{{%webhooks}}', 'redelivery_of', '{{%deliveries}}', 'id');
diff --git a/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php b/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php
index e88d0ea9..bad5d1a0 100644
--- a/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php
+++ b/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000000_create_table_deliveries.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%deliveries}}', [
             'id' => $this->primaryKey(),
-            'title' => $this->text()->null(),
+            'title' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php b/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php
index 591905a0..4ef0a10f 100644
--- a/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php
+++ b/tests/specs/fk_col_name_index/app/migrations_mysql_db/m200000_000002_create_table_webhooks.php
@@ -9,10 +9,10 @@ public function up()
     {
         $this->createTable('{{%webhooks}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->string(255)->null()->defaultValue(null),
-            'user_id' => $this->integer()->null()->defaultValue(null)->comment('Test model for model code generation that should not contain id column in rules'),
-            'redelivery_of' => $this->integer()->null()->defaultValue(null),
-            'rd_abc_2' => $this->integer()->null()->defaultValue(null),
+            'name' => $this->string(255)->notNull(),
+            'user_id' => $this->integer()->notNull()->comment('Test model for model code generation that should not contain id column in rules'),
+            'redelivery_of' => $this->integer()->notNull(),
+            'rd_abc_2' => $this->integer()->notNull(),
         ]);
         $this->createIndex('webhooks_user_id_name_key', '{{%webhooks}}', ["user_id", "name"], true);
         $this->createIndex('webhooks_redelivery_of_name_key', '{{%webhooks}}', ["redelivery_of", "name"], true);
diff --git a/tests/specs/issue_fix/58_create_migration_for_column_position_change_if_a_field_position_is_changed_in_spec/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php b/tests/specs/issue_fix/58_create_migration_for_column_position_change_if_a_field_position_is_changed_in_spec/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php
index 90ab0c79..c8228238 100644
--- a/tests/specs/issue_fix/58_create_migration_for_column_position_change_if_a_field_position_is_changed_in_spec/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/issue_fix/58_create_migration_for_column_position_change_if_a_field_position_is_changed_in_spec/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php
@@ -7,11 +7,11 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%fruits}}', 'name', $this->text()->null()->after('id'));
+        $this->alterColumn('{{%fruits}}', 'name', $this->text()->notNull()->after('id'));
     }
 
     public function down()
     {
-        $this->alterColumn('{{%fruits}}', 'name', $this->text()->null()->after('description'));
+        $this->alterColumn('{{%fruits}}', 'name', $this->text()->notNull()->after('description'));
     }
 }
diff --git a/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php
index 772ab122..85ba5a43 100644
--- a/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/mysql/migrations_mysql_db/m200000_000000_change_table_fruits.php
@@ -7,11 +7,11 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%fruits}}', 'name', $this->integer()->null()->defaultValue(null)->after('col')->comment('new desc'));
+        $this->alterColumn('{{%fruits}}', 'name', $this->integer()->notNull()->after('col')->comment('new desc'));
     }
 
     public function down()
     {
-        $this->alterColumn('{{%fruits}}', 'name', $this->text()->null()->after('id')->comment('desc'));
+        $this->alterColumn('{{%fruits}}', 'name', $this->text()->notNull()->after('id')->comment('desc'));
     }
 }
diff --git a/tests/specs/issue_fix/quote_in_alter_table/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php b/tests/specs/issue_fix/quote_in_alter_table/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
index 0472aa35..36c7f8c7 100644
--- a/tests/specs/issue_fix/quote_in_alter_table/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/issue_fix/quote_in_alter_table/pgsql/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
@@ -7,7 +7,7 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function safeUp()
     {
-        $this->alterColumn('{{%fruits}}', 'colourName', 'text NULL USING "colourName"::text');
+        $this->alterColumn('{{%fruits}}', 'colourName', 'text NOT NULL USING "colourName"::text');
     }
 
     public function safeDown()
diff --git a/tests/specs/many2many/migrations/m200000_000006_create_table_posts_gallery.php b/tests/specs/many2many/migrations/m200000_000006_create_table_posts_gallery.php
index aeb6c64f..fdc2184c 100644
--- a/tests/specs/many2many/migrations/m200000_000006_create_table_posts_gallery.php
+++ b/tests/specs/many2many/migrations/m200000_000006_create_table_posts_gallery.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%posts_gallery}}', [
             'image_id' => $this->bigInteger()->null()->defaultValue(null),
             'article_id' => $this->bigInteger()->null()->defaultValue(null),
-            'is_cover' => $this->text()->null(),
+            'is_cover' => $this->text()->notNull(),
         ]);
         $this->addPrimaryKey('pk_image_id_article_id', '{{%posts_gallery}}', 'image_id,article_id');
         $this->addForeignKey('fk_posts_gallery_image_id_photo_id', '{{%posts_gallery}}', 'image_id', '{{%photo}}', 'id');
diff --git a/tests/specs/menu/migrations/m200000_000000_create_table_menus.php b/tests/specs/menu/migrations/m200000_000000_create_table_menus.php
index c26156c3..b2161e8d 100644
--- a/tests/specs/menu/migrations/m200000_000000_create_table_menus.php
+++ b/tests/specs/menu/migrations/m200000_000000_create_table_menus.php
@@ -10,8 +10,8 @@ public function safeUp()
         $this->createTable('{{%menus}}', [
             'id' => $this->bigPrimaryKey(),
             'name' => $this->string(100)->notNull(),
-            'parent_id' => $this->bigInteger()->null()->defaultValue(null),
-            0 => '"args" text[] NULL DEFAULT \'{"foo","bar","baz"}\'',
+            'parent_id' => $this->bigInteger()->notNull(),
+            0 => '"args" text[] NOT NULL DEFAULT \'{"foo","bar","baz"}\'',
             1 => '"kwargs" json NOT NULL DEFAULT \'[{"foo":"bar"},{"buzz":"fizz"}]\'',
         ]);
         $this->addForeignKey('fk_menus_parent_id_menus_id', '{{%menus}}', 'parent_id', '{{%menus}}', 'id');
diff --git a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000000_change_table_addtwonewcolinbetween2s.php b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000000_change_table_addtwonewcolinbetween2s.php
index 544d1084..b62098e9 100644
--- a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000000_change_table_addtwonewcolinbetween2s.php
+++ b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000000_change_table_addtwonewcolinbetween2s.php
@@ -7,9 +7,9 @@ class m200000_000000_change_table_addtwonewcolinbetween2s extends \yii\db\Migrat
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN password text NULL DEFAULT NULL AFTER name')->execute();
-        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN screen_name text NULL DEFAULT NULL AFTER last_name')->execute();
-        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN nick_name text NULL DEFAULT NULL AFTER screen_name')->execute();
+        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN password text NOT NULL AFTER name')->execute();
+        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN screen_name text NOT NULL AFTER last_name')->execute();
+        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN nick_name text NOT NULL AFTER screen_name')->execute();
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000001_change_table_addtwonewcolinbetweens.php b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000001_change_table_addtwonewcolinbetweens.php
index b9648922..5a5ad402 100644
--- a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000001_change_table_addtwonewcolinbetweens.php
+++ b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000001_change_table_addtwonewcolinbetweens.php
@@ -7,9 +7,9 @@ class m200000_000001_change_table_addtwonewcolinbetweens extends \yii\db\Migrati
 {
     public function up()
     {
-        $this->addColumn('{{%addtwonewcolinbetweens}}', 'password', $this->text()->null()->defaultValue(null)->after('name'));
-        $this->addColumn('{{%addtwonewcolinbetweens}}', 'screen_name', $this->text()->null()->defaultValue(null)->after('last_name'));
-        $this->addColumn('{{%addtwonewcolinbetweens}}', 'nick_name', $this->text()->null()->defaultValue(null)->after('screen_name'));
+        $this->addColumn('{{%addtwonewcolinbetweens}}', 'password', $this->text()->notNull()->after('name'));
+        $this->addColumn('{{%addtwonewcolinbetweens}}', 'screen_name', $this->text()->notNull()->after('last_name'));
+        $this->addColumn('{{%addtwonewcolinbetweens}}', 'nick_name', $this->text()->notNull()->after('screen_name'));
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000006_change_table_twocol2s.php b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000006_change_table_twocol2s.php
index 45325e91..f3b5ecf8 100644
--- a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000006_change_table_twocol2s.php
+++ b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000006_change_table_twocol2s.php
@@ -7,8 +7,8 @@ class m200000_000006_change_table_twocol2s extends \yii\db\Migration
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN email text NULL DEFAULT NULL FIRST')->execute();
-        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN last_name text NULL DEFAULT NULL AFTER email')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN email text NOT NULL FIRST')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN last_name text NOT NULL AFTER email')->execute();
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000007_change_table_twocols.php b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000007_change_table_twocols.php
index d63f7443..713bbaae 100644
--- a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000007_change_table_twocols.php
+++ b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000007_change_table_twocols.php
@@ -7,8 +7,8 @@ class m200000_000007_change_table_twocols extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%twocols}}', 'email', $this->text()->null()->defaultValue(null)->first());
-        $this->addColumn('{{%twocols}}', 'last_name', $this->text()->null()->defaultValue(null)->after('email'));
+        $this->addColumn('{{%twocols}}', 'email', $this->text()->notNull()->first());
+        $this->addColumn('{{%twocols}}', 'last_name', $this->text()->notNull()->after('email'));
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000008_change_table_twonewcolatlast2s.php b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000008_change_table_twonewcolatlast2s.php
index 0a88452d..c622d7c5 100644
--- a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000008_change_table_twonewcolatlast2s.php
+++ b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000008_change_table_twonewcolatlast2s.php
@@ -7,8 +7,8 @@ class m200000_000008_change_table_twonewcolatlast2s extends \yii\db\Migration
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN name text NULL DEFAULT NULL AFTER email')->execute();
-        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN last_name text NULL DEFAULT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN name text NOT NULL AFTER email')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN last_name text NOT NULL')->execute();
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000009_change_table_twonewcolatlasts.php b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000009_change_table_twonewcolatlasts.php
index 0a332d7a..528a4971 100644
--- a/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000009_change_table_twonewcolatlasts.php
+++ b/tests/specs/new_column_position/maria/app/migrations_maria_db/m200000_000009_change_table_twonewcolatlasts.php
@@ -7,8 +7,8 @@ class m200000_000009_change_table_twonewcolatlasts extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%twonewcolatlasts}}', 'name', $this->integer()->null()->defaultValue(null)->after('email'));
-        $this->addColumn('{{%twonewcolatlasts}}', 'last_name', $this->integer()->null()->defaultValue(null));
+        $this->addColumn('{{%twonewcolatlasts}}', 'name', $this->integer()->notNull()->after('email'));
+        $this->addColumn('{{%twonewcolatlasts}}', 'last_name', $this->integer()->notNull());
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000000_change_table_addtwonewcolinbetween2s.php b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000000_change_table_addtwonewcolinbetween2s.php
index 7d4f8bfa..b62098e9 100644
--- a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000000_change_table_addtwonewcolinbetween2s.php
+++ b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000000_change_table_addtwonewcolinbetween2s.php
@@ -7,9 +7,9 @@ class m200000_000000_change_table_addtwonewcolinbetween2s extends \yii\db\Migrat
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN password text NULL AFTER name')->execute();
-        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN screen_name text NULL AFTER last_name')->execute();
-        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN nick_name text NULL AFTER screen_name')->execute();
+        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN password text NOT NULL AFTER name')->execute();
+        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN screen_name text NOT NULL AFTER last_name')->execute();
+        $this->db->createCommand('ALTER TABLE {{%addtwonewcolinbetween2s}} ADD COLUMN nick_name text NOT NULL AFTER screen_name')->execute();
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000001_change_table_addtwonewcolinbetweens.php b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000001_change_table_addtwonewcolinbetweens.php
index 355597ac..5a5ad402 100644
--- a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000001_change_table_addtwonewcolinbetweens.php
+++ b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000001_change_table_addtwonewcolinbetweens.php
@@ -7,9 +7,9 @@ class m200000_000001_change_table_addtwonewcolinbetweens extends \yii\db\Migrati
 {
     public function up()
     {
-        $this->addColumn('{{%addtwonewcolinbetweens}}', 'password', $this->text()->null()->after('name'));
-        $this->addColumn('{{%addtwonewcolinbetweens}}', 'screen_name', $this->text()->null()->after('last_name'));
-        $this->addColumn('{{%addtwonewcolinbetweens}}', 'nick_name', $this->text()->null()->after('screen_name'));
+        $this->addColumn('{{%addtwonewcolinbetweens}}', 'password', $this->text()->notNull()->after('name'));
+        $this->addColumn('{{%addtwonewcolinbetweens}}', 'screen_name', $this->text()->notNull()->after('last_name'));
+        $this->addColumn('{{%addtwonewcolinbetweens}}', 'nick_name', $this->text()->notNull()->after('screen_name'));
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000006_change_table_twocol2s.php b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000006_change_table_twocol2s.php
index 40e3d693..f3b5ecf8 100644
--- a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000006_change_table_twocol2s.php
+++ b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000006_change_table_twocol2s.php
@@ -7,8 +7,8 @@ class m200000_000006_change_table_twocol2s extends \yii\db\Migration
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN email text NULL FIRST')->execute();
-        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN last_name text NULL AFTER email')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN email text NOT NULL FIRST')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twocol2s}} ADD COLUMN last_name text NOT NULL AFTER email')->execute();
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000007_change_table_twocols.php b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000007_change_table_twocols.php
index 33c954e0..713bbaae 100644
--- a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000007_change_table_twocols.php
+++ b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000007_change_table_twocols.php
@@ -7,8 +7,8 @@ class m200000_000007_change_table_twocols extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%twocols}}', 'email', $this->text()->null()->first());
-        $this->addColumn('{{%twocols}}', 'last_name', $this->text()->null()->after('email'));
+        $this->addColumn('{{%twocols}}', 'email', $this->text()->notNull()->first());
+        $this->addColumn('{{%twocols}}', 'last_name', $this->text()->notNull()->after('email'));
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000008_change_table_twonewcolatlast2s.php b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000008_change_table_twonewcolatlast2s.php
index 60931d95..c622d7c5 100644
--- a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000008_change_table_twonewcolatlast2s.php
+++ b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000008_change_table_twonewcolatlast2s.php
@@ -7,8 +7,8 @@ class m200000_000008_change_table_twonewcolatlast2s extends \yii\db\Migration
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN name text NULL AFTER email')->execute();
-        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN last_name text NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN name text NOT NULL AFTER email')->execute();
+        $this->db->createCommand('ALTER TABLE {{%twonewcolatlast2s}} ADD COLUMN last_name text NOT NULL')->execute();
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000009_change_table_twonewcolatlasts.php b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000009_change_table_twonewcolatlasts.php
index 0a332d7a..528a4971 100644
--- a/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000009_change_table_twonewcolatlasts.php
+++ b/tests/specs/new_column_position/mysql/app/migrations_mysql_db/m200000_000009_change_table_twonewcolatlasts.php
@@ -7,8 +7,8 @@ class m200000_000009_change_table_twonewcolatlasts extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%twonewcolatlasts}}', 'name', $this->integer()->null()->defaultValue(null)->after('email'));
-        $this->addColumn('{{%twonewcolatlasts}}', 'last_name', $this->integer()->null()->defaultValue(null));
+        $this->addColumn('{{%twonewcolatlasts}}', 'name', $this->integer()->notNull()->after('email'));
+        $this->addColumn('{{%twonewcolatlasts}}', 'last_name', $this->integer()->notNull());
     }
 
     public function down()
diff --git a/tests/specs/new_column_position/new_column_position.yaml b/tests/specs/new_column_position/new_column_position.yaml
index 93d51ffb..ddd2470d 100644
--- a/tests/specs/new_column_position/new_column_position.yaml
+++ b/tests/specs/new_column_position/new_column_position.yaml
@@ -62,7 +62,6 @@ components:
           type: string
         address:
           type: string
-
     Dropfirstcol: # drop first column and see its `down()` code
       type: object
       description: Drop first column
diff --git a/tests/specs/petstore_jsonapi/migrations/m200000_000000_create_table_pets.php b/tests/specs/petstore_jsonapi/migrations/m200000_000000_create_table_pets.php
index 4d4c3bff..9132bcb9 100644
--- a/tests/specs/petstore_jsonapi/migrations/m200000_000000_create_table_pets.php
+++ b/tests/specs/petstore_jsonapi/migrations/m200000_000000_create_table_pets.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%pets}}', [
             'id' => $this->bigPrimaryKey(),
             'name' => $this->text()->notNull(),
-            'tag' => $this->text()->null(),
+            'tag' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/petstore_xtable/migrations/m200000_000000_create_table_pets.php b/tests/specs/petstore_xtable/migrations/m200000_000000_create_table_pets.php
index 4d4c3bff..9132bcb9 100644
--- a/tests/specs/petstore_xtable/migrations/m200000_000000_create_table_pets.php
+++ b/tests/specs/petstore_xtable/migrations/m200000_000000_create_table_pets.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%pets}}', [
             'id' => $this->bigPrimaryKey(),
             'name' => $this->text()->notNull(),
-            'tag' => $this->text()->null(),
+            'tag' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/x_db_default_expression/maria/edit/app/migrations_maria_db/m200000_000000_change_table_fruits.php b/tests/specs/x_db_default_expression/maria/edit/app/migrations_maria_db/m200000_000000_change_table_fruits.php
index 8bf7bff0..67093749 100644
--- a/tests/specs/x_db_default_expression/maria/edit/app/migrations_maria_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/x_db_default_expression/maria/edit/app/migrations_maria_db/m200000_000000_change_table_fruits.php
@@ -7,22 +7,22 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->null()->defaultValue('2000-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'd', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->null()->defaultValue('text default'));
-        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->notNull()->defaultValue('2000-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'd', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->notNull()->defaultValue('text default'));
+        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
     }
 
     public function down()
     {
         $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->null()->defaultValue(null));
-        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->null()->defaultValue(null));
+        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->notNull());
         $this->alterColumn('{{%fruits}}', 'd2', $this->text()->null()->defaultValue(null));
         $this->alterColumn('{{%fruits}}', 'd', $this->date()->null()->defaultValue(null));
         $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->notNull()->defaultValue('0000-00-00 00:00:00'));
diff --git a/tests/specs/x_db_default_expression/maria/edit_expression/app/migrations_maria_db/m200000_000000_change_table_fruits.php b/tests/specs/x_db_default_expression/maria/edit_expression/app/migrations_maria_db/m200000_000000_change_table_fruits.php
index f709a2fd..975b20d8 100644
--- a/tests/specs/x_db_default_expression/maria/edit_expression/app/migrations_maria_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/x_db_default_expression/maria/edit_expression/app/migrations_maria_db/m200000_000000_change_table_fruits.php
@@ -7,22 +7,22 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->null()->defaultValue('2000-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'd', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->null()->defaultValue('text default'));
-        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->notNull()->defaultValue('2000-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'd', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->notNull()->defaultValue('text default'));
+        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
     }
 
     public function down()
     {
         $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->null()->defaultValue('2011-11-11'));
-        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->null()->defaultValue(null));
+        $this->alterColumn('{{%fruits}}', 'd3', $this->text()->notNull());
         $this->alterColumn('{{%fruits}}', 'd2', $this->text()->null()->defaultValue(null));
         $this->alterColumn('{{%fruits}}', 'd', $this->date()->null()->defaultValue('2011-11-11'));
         $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->notNull()->defaultExpression("current_timestamp()"));
diff --git a/tests/specs/x_db_default_expression/maria/simple/app/migrations_maria_db/m200000_000000_create_table_fruits.php b/tests/specs/x_db_default_expression/maria/simple/app/migrations_maria_db/m200000_000000_create_table_fruits.php
index 8285456b..275c3d5a 100644
--- a/tests/specs/x_db_default_expression/maria/simple/app/migrations_maria_db/m200000_000000_create_table_fruits.php
+++ b/tests/specs/x_db_default_expression/maria/simple/app/migrations_maria_db/m200000_000000_create_table_fruits.php
@@ -8,16 +8,16 @@ class m200000_000000_create_table_fruits extends \yii\db\Migration
     public function up()
     {
         $this->createTable('{{%fruits}}', [
-            'ts' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
-            'ts2' => $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'),
-            'ts3' => $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'),
-            0 => 'ts4 timestamp NULL DEFAULT \'2022-11-11 00:00:00\'',
-            1 => 'ts5 timestamp NULL DEFAULT (CURRENT_TIMESTAMP)',
-            2 => 'ts6 timestamp NULL DEFAULT \'2000-11-11 00:00:00\'',
-            3 => 'd date NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
-            4 => 'd2 text NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
-            5 => 'd3 text NULL DEFAULT \'text default\'',
-            'ts7' => $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"),
+            'ts' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'ts2' => $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'),
+            'ts3' => $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'),
+            0 => 'ts4 timestamp NOT NULL DEFAULT \'2022-11-11 00:00:00\'',
+            1 => 'ts5 timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)',
+            2 => 'ts6 timestamp NOT NULL DEFAULT \'2000-11-11 00:00:00\'',
+            3 => 'd date NOT NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
+            4 => 'd2 text NOT NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
+            5 => 'd3 text NOT NULL DEFAULT \'text default\'',
+            'ts7' => $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"),
         ]);
     }
 
diff --git a/tests/specs/x_db_default_expression/mysql/edit/app/migrations_mysql_db/m200000_000000_change_table_fruits.php b/tests/specs/x_db_default_expression/mysql/edit/app/migrations_mysql_db/m200000_000000_change_table_fruits.php
index 01eefe40..74d6cc58 100644
--- a/tests/specs/x_db_default_expression/mysql/edit/app/migrations_mysql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/x_db_default_expression/mysql/edit/app/migrations_mysql_db/m200000_000000_change_table_fruits.php
@@ -7,15 +7,15 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->null()->defaultValue('2000-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'd', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->notNull()->defaultValue('2000-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'd', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
     }
 
     public function down()
diff --git a/tests/specs/x_db_default_expression/mysql/edit_expression/app/migrations_mysql_db/m200000_000000_change_table_fruits.php b/tests/specs/x_db_default_expression/mysql/edit_expression/app/migrations_mysql_db/m200000_000000_change_table_fruits.php
index b130a4fa..1e0f409e 100644
--- a/tests/specs/x_db_default_expression/mysql/edit_expression/app/migrations_mysql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/x_db_default_expression/mysql/edit_expression/app/migrations_mysql_db/m200000_000000_change_table_fruits.php
@@ -7,15 +7,15 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function up()
     {
-        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"));
-        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->null()->defaultValue('2000-11-11 00:00:00'));
-        $this->alterColumn('{{%fruits}}', 'd', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
-        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'ts', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts2', $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts3', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts4', $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'ts5', $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"));
+        $this->alterColumn('{{%fruits}}', 'ts6', $this->timestamp()->notNull()->defaultValue('2000-11-11 00:00:00'));
+        $this->alterColumn('{{%fruits}}', 'd', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'd2', $this->text()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
+        $this->alterColumn('{{%fruits}}', 'ts7', $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"));
     }
 
     public function down()
diff --git a/tests/specs/x_db_default_expression/mysql/simple/app/migrations_mysql_db/m200000_000000_create_table_fruits.php b/tests/specs/x_db_default_expression/mysql/simple/app/migrations_mysql_db/m200000_000000_create_table_fruits.php
index 11f7238b..286d0318 100644
--- a/tests/specs/x_db_default_expression/mysql/simple/app/migrations_mysql_db/m200000_000000_create_table_fruits.php
+++ b/tests/specs/x_db_default_expression/mysql/simple/app/migrations_mysql_db/m200000_000000_create_table_fruits.php
@@ -8,16 +8,16 @@ class m200000_000000_create_table_fruits extends \yii\db\Migration
     public function up()
     {
         $this->createTable('{{%fruits}}', [
-            'ts' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
-            'ts2' => $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'),
-            'ts3' => $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'),
-            0 => 'ts4 timestamp NULL DEFAULT \'2022-11-11 00:00:00\'',
-            1 => 'ts5 timestamp NULL DEFAULT (CURRENT_TIMESTAMP)',
-            2 => 'ts6 timestamp NULL DEFAULT \'2000-11-11 00:00:00\'',
-            3 => 'd date NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
-            4 => 'd2 text NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
-            5 => 'd3 text NULL',
-            'ts7' => $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"),
+            'ts' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'ts2' => $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'),
+            'ts3' => $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'),
+            0 => 'ts4 timestamp NOT NULL DEFAULT \'2022-11-11 00:00:00\'',
+            1 => 'ts5 timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)',
+            2 => 'ts6 timestamp NOT NULL DEFAULT \'2000-11-11 00:00:00\'',
+            3 => 'd date NOT NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
+            4 => 'd2 text NOT NULL DEFAULT (CURRENT_DATE + INTERVAL 1 YEAR)',
+            5 => 'd3 text NOT NULL',
+            'ts7' => $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL 1 YEAR)"),
         ]);
     }
 
diff --git a/tests/specs/x_db_default_expression/pgsql/edit/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php b/tests/specs/x_db_default_expression/pgsql/edit/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
index 22d85a96..6178dcd9 100644
--- a/tests/specs/x_db_default_expression/pgsql/edit/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/x_db_default_expression/pgsql/edit/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
@@ -7,29 +7,47 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function safeUp()
     {
+        $this->alterColumn('{{%fruits}}', 'ts', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts', "SET DEFAULT (CURRENT_TIMESTAMP)");
+        $this->alterColumn('{{%fruits}}', 'ts2', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts2', "SET DEFAULT '2011-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts3', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts3', "SET DEFAULT '2022-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts4', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts4', "SET DEFAULT '2022-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts5', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts5', "SET DEFAULT (CURRENT_TIMESTAMP)");
+        $this->alterColumn('{{%fruits}}', 'ts6', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts6', "SET DEFAULT '2000-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'd', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd', "SET DEFAULT (CURRENT_DATE + INTERVAL '1 YEAR')");
+        $this->alterColumn('{{%fruits}}', 'd2', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd2', "SET DEFAULT (CURRENT_DATE + INTERVAL '1 YEAR')");
         $this->alterColumn('{{%fruits}}', 'd3', "SET DEFAULT 'text default'");
+        $this->alterColumn('{{%fruits}}', 'ts7', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts7', "SET DEFAULT (CURRENT_DATE + INTERVAL '1 YEAR')");
     }
 
     public function safeDown()
     {
+        $this->alterColumn('{{%fruits}}', 'ts', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts2', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts2', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts3', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts3', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts4', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts4', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts5', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts5', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts6', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts6', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'd', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'd2', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd2', "DROP DEFAULT");
         $this->alterColumn('{{%fruits}}', 'd3', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts7', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts7', "DROP DEFAULT");
     }
 }
diff --git a/tests/specs/x_db_default_expression/pgsql/edit_expression/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php b/tests/specs/x_db_default_expression/pgsql/edit_expression/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
index 4372308e..9503125c 100644
--- a/tests/specs/x_db_default_expression/pgsql/edit_expression/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
+++ b/tests/specs/x_db_default_expression/pgsql/edit_expression/app/migrations_pgsql_db/m200000_000000_change_table_fruits.php
@@ -7,29 +7,47 @@ class m200000_000000_change_table_fruits extends \yii\db\Migration
 {
     public function safeUp()
     {
+        $this->alterColumn('{{%fruits}}', 'ts', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts', "SET DEFAULT (CURRENT_TIMESTAMP)");
+        $this->alterColumn('{{%fruits}}', 'ts2', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts2', "SET DEFAULT '2011-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts3', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts3', "SET DEFAULT '2022-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts4', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts4', "SET DEFAULT '2022-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts5', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts5', "SET DEFAULT (CURRENT_TIMESTAMP)");
+        $this->alterColumn('{{%fruits}}', 'ts6', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts6', "SET DEFAULT '2000-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'd', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd', "SET DEFAULT (CURRENT_DATE + INTERVAL '1 YEAR')");
+        $this->alterColumn('{{%fruits}}', 'd2', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd2', "SET DEFAULT (CURRENT_DATE + INTERVAL '1 YEAR')");
         $this->alterColumn('{{%fruits}}', 'd3', "SET DEFAULT 'text default'");
+        $this->alterColumn('{{%fruits}}', 'ts7', "SET NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts7', "SET DEFAULT (CURRENT_DATE + INTERVAL '1 YEAR')");
     }
 
     public function safeDown()
     {
+        $this->alterColumn('{{%fruits}}', 'ts', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts', "SET DEFAULT '2011-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts2', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts2', "SET DEFAULT CURRENT_TIMESTAMP");
+        $this->alterColumn('{{%fruits}}', 'ts3', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts3', "SET DEFAULT CURRENT_TIMESTAMP");
+        $this->alterColumn('{{%fruits}}', 'ts4', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts4', "SET DEFAULT CURRENT_TIMESTAMP");
+        $this->alterColumn('{{%fruits}}', 'ts5', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts5', "SET DEFAULT '2011-11-11 00:00:00'");
+        $this->alterColumn('{{%fruits}}', 'ts6', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts6', "SET DEFAULT CURRENT_TIMESTAMP");
+        $this->alterColumn('{{%fruits}}', 'd', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd', "SET DEFAULT '2011-11-11'");
+        $this->alterColumn('{{%fruits}}', 'd2', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'd2', "DROP DEFAULT");
         $this->alterColumn('{{%fruits}}', 'd3', "DROP DEFAULT");
+        $this->alterColumn('{{%fruits}}', 'ts7', "DROP NOT NULL");
         $this->alterColumn('{{%fruits}}', 'ts7', "SET DEFAULT '2011-11-11'");
     }
 }
diff --git a/tests/specs/x_db_default_expression/pgsql/simple/app/migrations_pgsql_db/m200000_000000_create_table_fruits.php b/tests/specs/x_db_default_expression/pgsql/simple/app/migrations_pgsql_db/m200000_000000_create_table_fruits.php
index 60533da5..77f0fac6 100644
--- a/tests/specs/x_db_default_expression/pgsql/simple/app/migrations_pgsql_db/m200000_000000_create_table_fruits.php
+++ b/tests/specs/x_db_default_expression/pgsql/simple/app/migrations_pgsql_db/m200000_000000_create_table_fruits.php
@@ -8,16 +8,16 @@ class m200000_000000_create_table_fruits extends \yii\db\Migration
     public function safeUp()
     {
         $this->createTable('{{%fruits}}', [
-            'ts' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
-            'ts2' => $this->timestamp()->null()->defaultValue('2011-11-11 00:00:00'),
-            'ts3' => $this->timestamp()->null()->defaultValue('2022-11-11 00:00:00'),
-            0 => '"ts4" timestamp NULL DEFAULT \'2022-11-11 00:00:00\'',
-            1 => '"ts5" timestamp NULL DEFAULT (CURRENT_TIMESTAMP)',
-            2 => '"ts6" timestamp NULL DEFAULT \'2000-11-11 00:00:00\'',
-            3 => '"d" date NULL DEFAULT (CURRENT_DATE + INTERVAL \'1 YEAR\')',
-            4 => '"d2" text NULL DEFAULT (CURRENT_DATE + INTERVAL \'1 YEAR\')',
-            5 => '"d3" text NULL DEFAULT \'text default\'',
-            'ts7' => $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL '1 YEAR')"),
+            'ts' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'ts2' => $this->timestamp()->notNull()->defaultValue('2011-11-11 00:00:00'),
+            'ts3' => $this->timestamp()->notNull()->defaultValue('2022-11-11 00:00:00'),
+            0 => '"ts4" timestamp NOT NULL DEFAULT \'2022-11-11 00:00:00\'',
+            1 => '"ts5" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)',
+            2 => '"ts6" timestamp NOT NULL DEFAULT \'2000-11-11 00:00:00\'',
+            3 => '"d" date NOT NULL DEFAULT (CURRENT_DATE + INTERVAL \'1 YEAR\')',
+            4 => '"d2" text NOT NULL DEFAULT (CURRENT_DATE + INTERVAL \'1 YEAR\')',
+            5 => '"d3" text NOT NULL DEFAULT \'text default\'',
+            'ts7' => $this->date()->notNull()->defaultExpression("(CURRENT_DATE + INTERVAL '1 YEAR')"),
         ]);
     }
 
diff --git a/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000000_create_table_userxes.php b/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000000_create_table_userxes.php
index b8e42166..c5910520 100644
--- a/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000000_create_table_userxes.php
+++ b/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000000_create_table_userxes.php
@@ -9,7 +9,7 @@ public function safeUp()
     {
         $this->createTable('{{%userxes}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null),
+            'name' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000001_create_table_postxes.php b/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000001_create_table_postxes.php
index 5593db95..b1f578d9 100644
--- a/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000001_create_table_postxes.php
+++ b/tests/specs/x_on_x_fk_constraint/app/migrations_pgsql_db/m200000_000001_create_table_postxes.php
@@ -9,11 +9,11 @@ public function safeUp()
     {
         $this->createTable('{{%postxes}}', [
             'id' => $this->primaryKey(),
-            'title' => $this->text()->null()->defaultValue(null),
-            'user_id' => $this->integer()->null()->defaultValue(null)->comment('x on-x (update|delete) foreign key constraint'),
-            'user_2_id' => $this->integer()->null()->defaultValue(null)->comment('x on-x (update|delete) foreign key constraint'),
-            'user_3_id' => $this->integer()->null()->defaultValue(null)->comment('x on-x (update|delete) foreign key constraint'),
-            'user_4_id' => $this->integer()->null()->defaultValue(null)->comment('x on-x (update|delete) foreign key constraint'),
+            'title' => $this->text()->notNull(),
+            'user_id' => $this->integer()->notNull()->comment('x on-x (update|delete) foreign key constraint'),
+            'user_2_id' => $this->integer()->notNull()->comment('x on-x (update|delete) foreign key constraint'),
+            'user_3_id' => $this->integer()->notNull()->comment('x on-x (update|delete) foreign key constraint'),
+            'user_4_id' => $this->integer()->notNull()->comment('x on-x (update|delete) foreign key constraint'),
         ]);
         $this->addForeignKey('fk_postxes_user_id_userxes_id', '{{%postxes}}', 'user_id', '{{%userxes}}', 'id', null, 'CASCADE');
         $this->addForeignKey('fk_postxes_user_2_id_userxes_id', '{{%postxes}}', 'user_2_id', '{{%userxes}}', 'id', 'SET NULL', 'CASCADE');
diff --git a/tests/unit/Issue58FixTest.php b/tests/unit/Issue58FixTest.php
index d4613e67..f6c902b6 100644
--- a/tests/unit/Issue58FixTest.php
+++ b/tests/unit/Issue58FixTest.php
@@ -32,8 +32,8 @@ private function createTableFor58CreateMigrationForColumnPositionChange()
     {
         Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
             'id' => 'pk',
-            'description' => 'text',
-            'name' => 'text',
+            'description' => 'text not null',
+            'name' => 'text not null',
         ])->execute();
     }
 
@@ -380,7 +380,8 @@ public function test58DeleteLast4Col()
         id:
           type: integer
         name:
-          type: boolean        
+          type: boolean
+          nullable: true        
 paths:
   '/':
     get:
@@ -442,8 +443,10 @@ public function test58DeleteFirst4Col()
       properties:        
         col_6:
           type: boolean
+          nullable: true
         col_7:
           type: boolean
+          nullable: true
 paths:
   '/':
     get:
diff --git a/tests/unit/IssueFixTest.php b/tests/unit/IssueFixTest.php
index ad3ff8fd..20c2e2f1 100644
--- a/tests/unit/IssueFixTest.php
+++ b/tests/unit/IssueFixTest.php
@@ -264,7 +264,6 @@ public function testCreateMigrationForDropTable132IndependentTablesDropSort()
         ])->execute();
 
         $this->runGenerator($testFile);
-        $this->runActualMigrations('mysql', 4);
 
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
@@ -273,6 +272,7 @@ public function testCreateMigrationForDropTable132IndependentTablesDropSort()
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('mysql', 4);
 
         $dropTables();
     }
@@ -285,7 +285,6 @@ public function testCreateMigrationForDropTable132()
         $this->deleteTablesForCreateMigrationForDropTable132();
         $this->createTablesForCreateMigrationForDropTable132();
         $this->runGenerator($testFile);
-        $this->runActualMigrations('mysql', 8);
 
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
@@ -294,6 +293,7 @@ public function testCreateMigrationForDropTable132()
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('mysql', 8);
 
         $this->deleteTablesForCreateMigrationForDropTable132();
     }
@@ -373,7 +373,6 @@ public function testCreateMigrationForDropTable132ForPgsql()
         $this->deleteTablesForCreateMigrationForDropTable132ForPgsql();
         $this->createTablesForCreateMigrationForDropTable132ForPgsql();
         $this->runGenerator($testFile, 'pgsql');
-        $this->runActualMigrations('pgsql', 8);
 
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
@@ -382,6 +381,7 @@ public function testCreateMigrationForDropTable132ForPgsql()
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('pgsql', 8);
 
         $this->deleteTablesForCreateMigrationForDropTable132ForPgsql();
     }
@@ -552,7 +552,6 @@ public function test60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnC
         $this->createTableFor60DescriptionOfAProperty();
         $testFile = Yii::getAlias("@specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/index.php");
         $this->runGenerator($testFile);
-        $this->runActualMigrations();
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
         ]);
@@ -560,6 +559,7 @@ public function test60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnC
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations();
         $this->deleteTableFor60DescriptionOfAProperty();
 
 
@@ -568,7 +568,6 @@ public function test60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnC
         $this->deleteTableFor60DescriptionOfAProperty();
         $this->createTableFor60DescriptionOfAProperty();
         $this->runGenerator($testFile, 'pgsql');
-        $this->runActualMigrations('pgsql');
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
             'except' => ['migrations_mysql_db']
@@ -577,6 +576,7 @@ public function test60DescriptionOfAPropertyInSpecMustCorrespondToDbTableColumnC
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('pgsql');
         $this->deleteTableFor60DescriptionOfAProperty();
     }
 
@@ -876,7 +876,6 @@ public function test25GenerateInverseRelations()
     {
         $testFile = Yii::getAlias("@specs/issue_fix/25_generate_inverse_relations/index.php");
         $this->runGenerator($testFile);
-        $this->runActualMigrations('mysql', 3);
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
         ]);
@@ -884,6 +883,7 @@ public function test25GenerateInverseRelations()
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('mysql', 3);
     }
 
     // https://github.com/php-openapi/yii2-openapi/issues/35
@@ -925,13 +925,12 @@ public function test63JustColumnNameRename()
         Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
         Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
             'id' => 'pk',
-            'name' => 'text',
-            'description' => 'text',
-            'colour' => 'text',
+            'name' => 'text not null',
+            'description' => 'text not null',
+            'colour' => 'text not null',
         ])->execute();
 
         $this->runGenerator($testFile);
-        $this->runActualMigrations('mysql', 1);
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
         ]);
@@ -939,6 +938,7 @@ public function test63JustColumnNameRename()
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('mysql', 1);
         Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
 
         // PgSQL
@@ -946,12 +946,11 @@ public function test63JustColumnNameRename()
         Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
         Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
             'id' => 'pk',
-            'name' => 'text',
-            'description' => 'text',
-            'colour' => 'text',
+            'name' => 'text not null',
+            'description' => 'text not null',
+            'colour' => 'text not null',
         ])->execute();
         $this->runGenerator($testFile, 'pgsql');
-        $this->runActualMigrations('pgsql', 1);
         $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
             'recursive' => true,
             'except' => ['migrations_mysql_db']
@@ -960,6 +959,7 @@ public function test63JustColumnNameRename()
             'recursive' => true,
         ]);
         $this->checkFiles($actualFiles, $expectedFiles);
+        $this->runActualMigrations('pgsql', 1);
         Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
     }
 
@@ -968,9 +968,9 @@ public function test64AddATestForAColumnChangeDataTypeCommentPositionAll3AreChan
         Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
         Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
             'id' => 'pk',
-            'name' => 'text comment "desc"',
-            'description' => 'text',
-            'col' => 'text',
+            'name' => 'text not null comment "desc"',
+            'description' => 'text not null',
+            'col' => 'text not null',
         ])->execute();
 
         $testFile = Yii::getAlias("@specs/issue_fix/64_add_a_test_for_a_column_change_data_type_comment_position_all_3_are_changed/index.php");
diff --git a/tests/unit/NewColumnPositionTest.php b/tests/unit/NewColumnPositionTest.php
index f43eabdd..b19df6cc 100644
--- a/tests/unit/NewColumnPositionTest.php
+++ b/tests/unit/NewColumnPositionTest.php
@@ -51,24 +51,24 @@ public function testAddOneNewColumnAtFirstPosition()
     private function createTables()
     {
         Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
-            'email' => 'text'
+            'email' => 'text not null',
         ])->execute();
         Yii::$app->db->createCommand()->createTable('{{%fruit2s}}', [
-            'email' => 'text'
+            'email' => 'text not null',
         ])->execute();
 
         Yii::$app->db->createCommand()->createTable('{{%twocols}}', [
-            'name' => 'text',
-            'address' => 'text',
+            'name' => 'text not null',
+            'address' => 'text not null',
         ])->execute();
         Yii::$app->db->createCommand()->createTable('{{%twocol2s}}', [
-            'name' => 'text',
-            'address' => 'text',
+            'name' => 'text not null',
+            'address' => 'text not null',
         ])->execute();
 
         Yii::$app->db->createCommand()->createTable('{{%dropfirstcols}}', [
             'name' => 'text',
-            'address' => 'text',
+            'address' => 'text not null',
         ])->execute();
 
         // not relavant because data type is fetched from DB and not x-db-type
@@ -80,28 +80,28 @@ private function createTables()
         Yii::$app->db->createCommand()->createTable('{{%dropfirsttwocols}}', [
             'name' => 'text',
             'address' => 'text',
-            'last_name' => 'text',
-            'email' => 'text',
+            'last_name' => 'text not null',
+            'email' => 'text not null',
         ])->execute();
 
         Yii::$app->db->createCommand()->createTable('{{%addtwonewcolinbetweens}}', [
-            'name' => 'text',
-            'address' => 'text',
-            'last_name' => 'text',
-            'email' => 'text',
+            'name' => 'text not null',
+            'address' => 'text not null',
+            'last_name' => 'text not null',
+            'email' => 'text not null',
         ])->execute();
         Yii::$app->db->createCommand()->createTable('{{%addtwonewcolinbetween2s}}', [
-            'name' => 'text',
-            'address' => 'text',
-            'last_name' => 'text',
-            'email' => 'text',
+            'name' => 'text not null',
+            'address' => 'text not null',
+            'last_name' => 'text not null',
+            'email' => 'text not null',
         ])->execute();
 
         Yii::$app->db->createCommand()->createTable('{{%twonewcolatlasts}}', [
-            'email' => 'text'
+            'email' => 'text not null',
         ])->execute();
         Yii::$app->db->createCommand()->createTable('{{%twonewcolatlast2s}}', [
-            'email' => 'text'
+            'email' => 'text not null',
         ])->execute();
     }
 
diff --git a/tests/unit/XDbDefaultExpressionTest.php b/tests/unit/XDbDefaultExpressionTest.php
index 923a0fef..74b455c9 100644
--- a/tests/unit/XDbDefaultExpressionTest.php
+++ b/tests/unit/XDbDefaultExpressionTest.php
@@ -132,7 +132,7 @@ private function createTablesForEdit()
             'ts6' => 'timestamp',
             'd' => 'date',
             'd2' => 'text',
-            'd3' => 'text',
+            'd3' => 'text not null',
             'ts7' => 'date',
         ])->execute();
     }
@@ -199,7 +199,7 @@ private function createTablesForEditExpression()
             'ts6' => 'timestamp DEFAULT CURRENT_TIMESTAMP',
             'd' => 'date DEFAULT \'2011-11-11\'',
             'd2' => 'text', // DEFAULT "2011-11-11"
-            'd3' => 'text', // DEFAULT CURRENT_DATE + INTERVAL 1 YEAR
+            'd3' => 'text not null', // DEFAULT CURRENT_DATE + INTERVAL 1 YEAR
             'ts7' => 'date DEFAULT \'2011-11-11\'',
 
             // https://github.com/yiisoft/yii2/issues/19747

From b80fcd6f5b4b86eb62cf775ab2d046ebdea0d88e Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Mon, 10 Mar 2025 18:07:50 +0530
Subject: [PATCH 05/12] Change lot of tests 2 - Fix failing tests

---
 .../m200000_000001_create_table_users.php     |  6 +--
 ...m200000_000002_create_table_blog_posts.php |  6 +--
 .../m200000_000003_create_table_fakerable.php | 28 ++++++-------
 .../m200000_000001_create_table_foos.php      |  2 +-
 .../m200000_000000_create_table_foos.php      |  2 +-
 .../m200000_000000_create_table_foos.php      |  2 +-
 .../app/models/base/Pristine.php              |  1 -
 .../m200000_000000_create_table_accounts.php  |  2 +-
 .../m200000_000001_create_table_contacts.php  |  4 +-
 .../m200000_000000_create_table_fruits.php    |  2 +-
 .../m200000_000001_create_table_pets.php      | 32 +++++++--------
 .../m200000_000002_create_table_users.php     |  2 +-
 .../m200000_000000_create_table_accounts.php  |  2 +-
 .../m200000_000001_create_table_accounts.php  |  8 ++--
 .../m200000_000002_create_table_menus.php     |  2 +-
 .../m200000_000000_create_table_users.php     |  2 +-
 .../m200000_000001_create_table_posts.php     |  4 +-
 .../m200000_000000_change_table_animals.php   | 20 +++++-----
 .../m200000_000001_create_table_fruits.php    |  4 +-
 .../m200000_000000_change_table_animals.php   | 12 +++---
 .../m200000_000001_create_table_fruits.php    |  4 +-
 .../m200000_000000_create_table_pristines.php |  4 +-
 .../m200000_000000_create_table_pristines.php |  4 +-
 .../timestamp_143/mysql/timestamp_143.yaml    |  4 ++
 tests/unit/Issue58FixTest.php                 | 39 +++++++++++++++++--
 tests/unit/IssueFixTest.php                   | 20 +++++-----
 26 files changed, 126 insertions(+), 92 deletions(-)

diff --git a/tests/specs/blog/migrations_maria_db/m200000_000001_create_table_users.php b/tests/specs/blog/migrations_maria_db/m200000_000001_create_table_users.php
index a90792e9..813b1c95 100644
--- a/tests/specs/blog/migrations_maria_db/m200000_000001_create_table_users.php
+++ b/tests/specs/blog/migrations_maria_db/m200000_000001_create_table_users.php
@@ -12,9 +12,9 @@ public function up()
             'username' => $this->string(200)->notNull(),
             'email' => $this->string(200)->notNull(),
             'password' => $this->string()->notNull(),
-            'role' => $this->string(20)->null()->defaultValue('reader'),
-            'flags' => $this->integer()->null()->defaultValue(0),
-            'created_at' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'role' => $this->string(20)->notNull()->defaultValue('reader'),
+            'flags' => $this->integer()->notNull()->defaultValue(0),
+            'created_at' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
         ]);
         $this->createIndex('users_username_key', '{{%users}}', 'username', true);
         $this->createIndex('users_email_key', '{{%users}}', 'email', true);
diff --git a/tests/specs/blog/migrations_maria_db/m200000_000002_create_table_blog_posts.php b/tests/specs/blog/migrations_maria_db/m200000_000002_create_table_blog_posts.php
index c7cc90fb..acb248b0 100644
--- a/tests/specs/blog/migrations_maria_db/m200000_000002_create_table_blog_posts.php
+++ b/tests/specs/blog/migrations_maria_db/m200000_000002_create_table_blog_posts.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%blog_posts}}', [
             0 => 'uid varchar(128) NOT NULL',
             'title' => $this->string(255)->notNull(),
-            'slug' => $this->string(200)->null()->defaultValue(null),
+            'slug' => $this->string(200)->notNull(),
             'category_id' => $this->integer()->notNull()->comment('Category of posts'),
             'active' => $this->boolean()->notNull()->defaultValue(false),
-            'created_at' => $this->date()->null()->defaultValue(null),
-            'created_by_id' => $this->integer()->null()->defaultValue(null)->comment('The User'),
+            'created_at' => $this->date()->notNull(),
+            'created_by_id' => $this->integer()->notNull()->comment('The User'),
         ]);
         $this->addPrimaryKey('pk_blog_posts_uid', '{{%blog_posts}}', 'uid');
         $this->createIndex('blog_posts_title_key', '{{%blog_posts}}', 'title', true);
diff --git a/tests/specs/blog/migrations_maria_db/m200000_000003_create_table_fakerable.php b/tests/specs/blog/migrations_maria_db/m200000_000003_create_table_fakerable.php
index 84f6247c..bd7b21f4 100644
--- a/tests/specs/blog/migrations_maria_db/m200000_000003_create_table_fakerable.php
+++ b/tests/specs/blog/migrations_maria_db/m200000_000003_create_table_fakerable.php
@@ -9,20 +9,20 @@ public function up()
     {
         $this->createTable('{{%fakerable}}', [
             'id' => $this->bigPrimaryKey(),
-            'active' => $this->boolean()->null()->defaultValue(null),
-            'floatval' => $this->float()->null()->defaultValue(null),
-            'floatval_lim' => $this->float()->null()->defaultValue(null),
-            'doubleval' => $this->double()->null()->defaultValue(null),
-            'int_min' => $this->integer()->null()->defaultValue(3),
-            'int_max' => $this->integer()->null()->defaultValue(null),
-            'int_minmax' => $this->integer()->null()->defaultValue(null),
-            'int_created_at' => $this->integer()->null()->defaultValue(null),
-            'int_simple' => $this->integer()->null()->defaultValue(null),
-            'str_text' => $this->text()->null()->defaultValue(null),
-            'str_varchar' => $this->string(100)->null()->defaultValue(null),
-            'str_date' => $this->date()->null()->defaultValue(null),
-            'str_datetime' => $this->timestamp()->null()->defaultValue(null),
-            'str_country' => $this->text()->null()->defaultValue(null),
+            'active' => $this->boolean()->notNull(),
+            'floatval' => $this->float()->notNull(),
+            'floatval_lim' => $this->float()->notNull(),
+            'doubleval' => $this->double()->notNull(),
+            'int_min' => $this->integer()->notNull()->defaultValue(3),
+            'int_max' => $this->integer()->notNull(),
+            'int_minmax' => $this->integer()->notNull(),
+            'int_created_at' => $this->integer()->notNull(),
+            'int_simple' => $this->integer()->notNull(),
+            'str_text' => $this->text()->notNull(),
+            'str_varchar' => $this->string(100)->notNull(),
+            'str_date' => $this->date()->notNull(),
+            'str_datetime' => $this->timestamp()->notNull(),
+            'str_country' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql/migrations_mysql_db/m200000_000001_create_table_foos.php b/tests/specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql/migrations_mysql_db/m200000_000001_create_table_foos.php
index 9f90d171..2ff7a479 100644
--- a/tests/specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql/migrations_mysql_db/m200000_000001_create_table_foos.php
+++ b/tests/specs/issue_fix/132_create_migration_for_drop_table/case_independent_tables_drop_sort/mysql/migrations_mysql_db/m200000_000001_create_table_foos.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%foos}}', [
             'id' => $this->primaryKey(),
-            'factor' => $this->integer()->null()->defaultValue(null),
+            'factor' => $this->integer()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/132_create_migration_for_drop_table/mysql/migrations_mysql_db/m200000_000000_create_table_foos.php b/tests/specs/issue_fix/132_create_migration_for_drop_table/mysql/migrations_mysql_db/m200000_000000_create_table_foos.php
index 1e71fcd5..25486b97 100644
--- a/tests/specs/issue_fix/132_create_migration_for_drop_table/mysql/migrations_mysql_db/m200000_000000_create_table_foos.php
+++ b/tests/specs/issue_fix/132_create_migration_for_drop_table/mysql/migrations_mysql_db/m200000_000000_create_table_foos.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%foos}}', [
             'id' => $this->primaryKey(),
-            'factor' => $this->integer()->null()->defaultValue(null),
+            'factor' => $this->integer()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/132_create_migration_for_drop_table/pgsql/migrations_pgsql_db/m200000_000000_create_table_foos.php b/tests/specs/issue_fix/132_create_migration_for_drop_table/pgsql/migrations_pgsql_db/m200000_000000_create_table_foos.php
index 268bd109..9f7145e8 100644
--- a/tests/specs/issue_fix/132_create_migration_for_drop_table/pgsql/migrations_pgsql_db/m200000_000000_create_table_foos.php
+++ b/tests/specs/issue_fix/132_create_migration_for_drop_table/pgsql/migrations_pgsql_db/m200000_000000_create_table_foos.php
@@ -9,7 +9,7 @@ public function safeUp()
     {
         $this->createTable('{{%foos}}', [
             'id' => $this->primaryKey(),
-            'factor' => $this->integer()->null()->defaultValue(null),
+            'factor' => $this->integer()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/153_nullable_false_in_required/app/models/base/Pristine.php b/tests/specs/issue_fix/153_nullable_false_in_required/app/models/base/Pristine.php
index 0aab2fad..ccec26d4 100644
--- a/tests/specs/issue_fix/153_nullable_false_in_required/app/models/base/Pristine.php
+++ b/tests/specs/issue_fix/153_nullable_false_in_required/app/models/base/Pristine.php
@@ -24,7 +24,6 @@ public function rules()
     {
         return [
             'billing_factor_default' => [['billing_factor'], 'default', 'value' => 100],
-            'required' => [['billing_factor'], 'required'],
             'billing_factor_integer' => [['billing_factor'], 'integer'],
         ];
     }
diff --git a/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000000_create_table_accounts.php b/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000000_create_table_accounts.php
index ce7db4f9..daf646fb 100644
--- a/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000000_create_table_accounts.php
+++ b/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000000_create_table_accounts.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%accounts}}', [
             'id' => $this->primaryKey(),
             'name' => $this->string(128)->notNull()->comment('account name'),
-            'paymentMethodName' => $this->text()->null(),
+            'paymentMethodName' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000001_create_table_contacts.php b/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000001_create_table_contacts.php
index a706a626..448959de 100644
--- a/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000001_create_table_contacts.php
+++ b/tests/specs/issue_fix/175_bug_allof_with_multiple_dollarrefs/pgsql/migrations_pgsql_db/m200000_000001_create_table_contacts.php
@@ -10,8 +10,8 @@ public function up()
         $this->createTable('{{%contacts}}', [
             'id' => $this->primaryKey(),
             'account_id' => $this->integer()->notNull()->comment('Account'),
-            'active' => $this->boolean()->null()->defaultValue(false),
-            'nickname' => $this->text()->null(),
+            'active' => $this->boolean()->notNull()->defaultValue(false),
+            'nickname' => $this->text()->notNull(),
         ]);
         $this->addForeignKey('fk_contacts_account_id_accounts_id', '{{%contacts}}', 'account_id', '{{%accounts}}', 'id');
     }
diff --git a/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000000_create_table_fruits.php b/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000000_create_table_fruits.php
index 18bf5d9f..1a562679 100644
--- a/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000000_create_table_fruits.php
+++ b/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000000_create_table_fruits.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%fruits}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null(),
+            'name' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000001_create_table_pets.php b/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000001_create_table_pets.php
index 01df98f3..c50525c9 100644
--- a/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000001_create_table_pets.php
+++ b/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000001_create_table_pets.php
@@ -10,22 +10,22 @@ public function up()
         $this->createTable('{{%pets}}', [
             'id' => $this->primaryKey(),
             'name' => $this->text()->notNull(),
-            'age' => $this->integer()->null()->defaultValue(null),
-            'tags' => $this->text()->null(),
-            'tags_arbit' => $this->text()->null(),
-            'number_arr' => $this->text()->null(),
-            'number_arr_min_uniq' => $this->text()->null(),
-            'int_arr' => $this->text()->null(),
-            'int_arr_min_uniq' => $this->text()->null(),
-            'bool_arr' => $this->text()->null(),
-            'arr_arr_int' => $this->text()->null(),
-            'arr_arr_str' => $this->text()->null(),
-            'arr_arr_arr_str' => $this->text()->null(),
-            'arr_of_obj' => $this->text()->null(),
-            'user_ref_obj_arr' => $this->string()->null()->defaultValue(null),
-            'one_of_arr' => $this->text()->null(),
-            'one_of_arr_complex' => $this->text()->null(),
-            'one_of_from_multi_ref_arr' => $this->text()->null(),
+            'age' => $this->integer()->notNull(),
+            'tags' => $this->text()->notNull(),
+            'tags_arbit' => $this->text()->notNull(),
+            'number_arr' => $this->text()->notNull(),
+            'number_arr_min_uniq' => $this->text()->notNull(),
+            'int_arr' => $this->text()->notNull(),
+            'int_arr_min_uniq' => $this->text()->notNull(),
+            'bool_arr' => $this->text()->notNull(),
+            'arr_arr_int' => $this->text()->notNull(),
+            'arr_arr_str' => $this->text()->notNull(),
+            'arr_arr_arr_str' => $this->text()->notNull(),
+            'arr_of_obj' => $this->text()->notNull(),
+            'user_ref_obj_arr' => $this->string()->notNull(),
+            'one_of_arr' => $this->text()->notNull(),
+            'one_of_arr_complex' => $this->text()->notNull(),
+            'one_of_from_multi_ref_arr' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000002_create_table_users.php b/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000002_create_table_users.php
index 0aa915a3..47292eda 100644
--- a/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000002_create_table_users.php
+++ b/tests/specs/issue_fix/20_consider_openapi_spec_examples_in_faker_code_generation/mysql/migrations_mysql_db/m200000_000002_create_table_users.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%users}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null(),
+            'name' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/22_bug_rules_required_is_generated_before_default/mysql/migrations_mysql_db/m200000_000000_create_table_accounts.php b/tests/specs/issue_fix/22_bug_rules_required_is_generated_before_default/mysql/migrations_mysql_db/m200000_000000_create_table_accounts.php
index 584fc0ee..7f6dc89b 100644
--- a/tests/specs/issue_fix/22_bug_rules_required_is_generated_before_default/mysql/migrations_mysql_db/m200000_000000_create_table_accounts.php
+++ b/tests/specs/issue_fix/22_bug_rules_required_is_generated_before_default/mysql/migrations_mysql_db/m200000_000000_create_table_accounts.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%accounts}}', [
             'id' => $this->primaryKey(),
             'name' => $this->string(128)->notNull()->comment('account name'),
-            'paymentMethodName' => $this->text()->null(),
+            'paymentMethodName' => $this->text()->notNull(),
             'verified' => $this->boolean()->notNull()->defaultValue(false),
         ]);
     }
diff --git a/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000001_create_table_accounts.php b/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000001_create_table_accounts.php
index 1bc93a24..61688dc7 100644
--- a/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000001_create_table_accounts.php
+++ b/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000001_create_table_accounts.php
@@ -10,10 +10,10 @@ public function up()
         $this->createTable('{{%accounts}}', [
             'id' => $this->primaryKey(),
             'name' => $this->string(128)->notNull()->comment('account name'),
-            'paymentMethodName' => $this->text()->null(),
-            'user_id' => $this->integer()->null()->defaultValue(null),
-            'user2_id' => $this->integer()->null()->defaultValue(null),
-            'user3' => $this->integer()->null()->defaultValue(null),
+            'paymentMethodName' => $this->text()->notNull(),
+            'user_id' => $this->integer()->notNull(),
+            'user2_id' => $this->integer()->notNull(),
+            'user3' => $this->integer()->notNull(),
         ]);
         $this->addForeignKey('fk_accounts_user_id_users_id', '{{%accounts}}', 'user_id', '{{%users}}', 'id');
         $this->addForeignKey('fk_accounts_user2_id_users_id', '{{%accounts}}', 'user2_id', '{{%users}}', 'id');
diff --git a/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000002_create_table_menus.php b/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000002_create_table_menus.php
index 78011c88..105978bc 100644
--- a/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000002_create_table_menus.php
+++ b/tests/specs/issue_fix/25_generate_inverse_relations/mysql/migrations_mysql_db/m200000_000002_create_table_menus.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%menus}}', [
             'id' => $this->bigPrimaryKey(),
             'name' => $this->string(100)->notNull(),
-            'parent_id' => $this->bigInteger()->null()->defaultValue(null),
+            'parent_id' => $this->bigInteger()->notNull(),
         ]);
         $this->addForeignKey('fk_menus_parent_id_menus_id', '{{%menus}}', 'parent_id', '{{%menus}}', 'id');
     }
diff --git a/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000000_create_table_users.php b/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000000_create_table_users.php
index 9ab60f3e..2616e0a4 100644
--- a/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000000_create_table_users.php
+++ b/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000000_create_table_users.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%users}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null(),
+            'name' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000001_create_table_posts.php b/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000001_create_table_posts.php
index ebb98b8e..6d03f3fe 100644
--- a/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000001_create_table_posts.php
+++ b/tests/specs/issue_fix/29_extension_fk_column_name_cause_error_in_case_of_column_name_without_underscore/mysql/migrations_mysql_db/m200000_000001_create_table_posts.php
@@ -9,8 +9,8 @@ public function up()
     {
         $this->createTable('{{%posts}}', [
             'id' => $this->primaryKey(),
-            'content' => $this->text()->null(),
-            'user' => $this->integer()->null()->defaultValue(null),
+            'content' => $this->text()->notNull(),
+            'user' => $this->integer()->notNull(),
         ]);
         $this->addForeignKey('fk_posts_user_users_id', '{{%posts}}', 'user', '{{%users}}', 'id');
     }
diff --git a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000000_change_table_animals.php b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000000_change_table_animals.php
index bff6c78d..369e21c5 100644
--- a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000000_change_table_animals.php
+++ b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000000_change_table_animals.php
@@ -7,21 +7,21 @@ class m200000_000000_change_table_animals extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%animals}}', 'new_col', $this->text()->null()->comment('new col added'));
+        $this->addColumn('{{%animals}}', 'new_col', $this->text()->notNull()->comment('new col added'));
         $this->dropColumn('{{%animals}}', 'drop_col');
-        $this->alterColumn('{{%animals}}', 'name', $this->integer()->null()->defaultValue(null));
-        $this->alterColumn('{{%animals}}', 'g', $this->text()->null()->comment('desc for g'));
-        $this->alterColumn('{{%animals}}', 'g2', $this->text()->null()->comment('changed comment on g2 col'));
-        $this->alterColumn('{{%animals}}', 'g4', $this->integer()->null()->defaultValue(null)->comment('data type changes but comment remains same'));
+        $this->alterColumn('{{%animals}}', 'name', $this->integer()->notNull());
+        $this->alterColumn('{{%animals}}', 'g', $this->text()->notNull()->comment('desc for g'));
+        $this->alterColumn('{{%animals}}', 'g2', $this->text()->notNull()->comment('changed comment on g2 col'));
+        $this->alterColumn('{{%animals}}', 'g4', $this->integer()->notNull()->comment('data type changes but comment remains same'));
     }
 
     public function down()
     {
-        $this->alterColumn('{{%animals}}', 'g4', $this->text()->null()->comment('data type changes but comment remains same'));
-        $this->alterColumn('{{%animals}}', 'g2', $this->text()->null()->comment('the comment on g2 col'));
-        $this->alterColumn('{{%animals}}', 'g', $this->text()->null());
-        $this->alterColumn('{{%animals}}', 'name', $this->text()->null()->comment('the comment on name col'));
-        $this->addColumn('{{%animals}}', 'drop_col', $this->text()->null());
+        $this->alterColumn('{{%animals}}', 'g4', $this->text()->notNull()->comment('data type changes but comment remains same'));
+        $this->alterColumn('{{%animals}}', 'g2', $this->text()->notNull()->comment('the comment on g2 col'));
+        $this->alterColumn('{{%animals}}', 'g', $this->text()->notNull());
+        $this->alterColumn('{{%animals}}', 'name', $this->text()->notNull()->comment('the comment on name col'));
+        $this->addColumn('{{%animals}}', 'drop_col', $this->text()->notNull());
         $this->dropColumn('{{%animals}}', 'new_col');
     }
 }
diff --git a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000001_create_table_fruits.php b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000001_create_table_fruits.php
index c4271f02..f5abdaa5 100644
--- a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000001_create_table_fruits.php
+++ b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/mysql/migrations_mysql_db/m200000_000001_create_table_fruits.php
@@ -9,8 +9,8 @@ public function up()
     {
         $this->createTable('{{%fruits}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->comment('desc with \' quote'),
-            0 => 'description double precision NULL DEFAULT NULL COMMENT \'desc \\\' 2\'',
+            'name' => $this->text()->notNull()->comment('desc with \' quote'),
+            0 => 'description double precision NOT NULL COMMENT \'desc \\\' 2\'',
         ]);
     }
 
diff --git a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000000_change_table_animals.php b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000000_change_table_animals.php
index ede74a69..20fc7abb 100644
--- a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000000_change_table_animals.php
+++ b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000000_change_table_animals.php
@@ -7,23 +7,23 @@ class m200000_000000_change_table_animals extends \yii\db\Migration
 {
     public function safeUp()
     {
-        $this->addColumn('{{%animals}}', 'new_col', $this->text()->null()->defaultValue(null)->comment('new col added'));
+        $this->addColumn('{{%animals}}', 'new_col', $this->text()->notNull()->comment('new col added'));
         $this->dropColumn('{{%animals}}', 'drop_col');
-        $this->alterColumn('{{%animals}}', 'name', 'int4 NULL USING "name"::int4');
+        $this->alterColumn('{{%animals}}', 'name', 'int4 NOT NULL USING "name"::int4');
         $this->dropCommentFromColumn('{{%animals}}', 'name');
         $this->addCommentOnColumn('{{%animals}}', 'g', 'desc for g');
         $this->addCommentOnColumn('{{%animals}}', 'g2', 'changed comment on g2 col');
-        $this->alterColumn('{{%animals}}', 'g4', 'int4 NULL USING "g4"::int4');
+        $this->alterColumn('{{%animals}}', 'g4', 'int4 NOT NULL USING "g4"::int4');
     }
 
     public function safeDown()
     {
-        $this->alterColumn('{{%animals}}', 'g4', 'text NULL USING "g4"::text');
+        $this->alterColumn('{{%animals}}', 'g4', 'text NOT NULL USING "g4"::text');
         $this->dropCommentFromColumn('{{%animals}}', 'g2');
         $this->dropCommentFromColumn('{{%animals}}', 'g');
         $this->addCommentOnColumn('{{%animals}}', 'name', 'the comment on name col');
-        $this->alterColumn('{{%animals}}', 'name', 'text NULL USING "name"::text');
-        $this->addColumn('{{%animals}}', 'drop_col', $this->text()->null()->defaultValue(null));
+        $this->alterColumn('{{%animals}}', 'name', 'text NOT NULL USING "name"::text');
+        $this->addColumn('{{%animals}}', 'drop_col', $this->text()->notNull());
         $this->dropColumn('{{%animals}}', 'new_col');
     }
 }
diff --git a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000001_create_table_fruits.php b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000001_create_table_fruits.php
index 21467feb..6814c943 100644
--- a/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000001_create_table_fruits.php
+++ b/tests/specs/issue_fix/60_description_of_a_property_in_spec_must_correspond_to_db_table_column_comment/pgsql/migrations_pgsql_db/m200000_000001_create_table_fruits.php
@@ -9,8 +9,8 @@ public function safeUp()
     {
         $this->createTable('{{%fruits}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null)->comment('desc with \' quote'),
-            0 => '"description" double precision NULL DEFAULT NULL',
+            'name' => $this->text()->notNull()->comment('desc with \' quote'),
+            0 => '"description" double precision NOT NULL',
         ]);
         $this->addCommentOnColumn('{{%fruits}}', 'name', 'desc with \' quote');
         $this->addCommentOnColumn('{{%fruits}}', 'description', 'desc \' 2');
diff --git a/tests/specs/issue_fix/camel_case_127/mysql/app/migrations_mysql_db/m200000_000000_create_table_pristines.php b/tests/specs/issue_fix/camel_case_127/mysql/app/migrations_mysql_db/m200000_000000_create_table_pristines.php
index a99836ac..80bb474a 100644
--- a/tests/specs/issue_fix/camel_case_127/mysql/app/migrations_mysql_db/m200000_000000_create_table_pristines.php
+++ b/tests/specs/issue_fix/camel_case_127/mysql/app/migrations_mysql_db/m200000_000000_create_table_pristines.php
@@ -9,8 +9,8 @@ public function up()
     {
         $this->createTable('{{%pristines}}', [
             'id' => $this->primaryKey(),
-            'firstName' => $this->text()->null(),
-            0 => 'newColumn varchar(255) NULL DEFAULT NULL',
+            'firstName' => $this->text()->notNull(),
+            0 => 'newColumn varchar(255) NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/issue_fix/camel_case_127/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_pristines.php b/tests/specs/issue_fix/camel_case_127/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_pristines.php
index 8b22758a..a2efb10e 100644
--- a/tests/specs/issue_fix/camel_case_127/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_pristines.php
+++ b/tests/specs/issue_fix/camel_case_127/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_pristines.php
@@ -9,8 +9,8 @@ public function safeUp()
     {
         $this->createTable('{{%pristines}}', [
             'id' => $this->primaryKey(),
-            'firstName' => $this->text()->null()->defaultValue(null),
-            0 => '"newColumn" varchar(255) NULL DEFAULT NULL',
+            'firstName' => $this->text()->notNull(),
+            0 => '"newColumn" varchar(255) NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/issue_fix/timestamp_143/mysql/timestamp_143.yaml b/tests/specs/issue_fix/timestamp_143/mysql/timestamp_143.yaml
index 9d680eb9..b53fe543 100644
--- a/tests/specs/issue_fix/timestamp_143/mysql/timestamp_143.yaml
+++ b/tests/specs/issue_fix/timestamp_143/mysql/timestamp_143.yaml
@@ -32,9 +32,13 @@ components:
           format: date-time
           example: '2020-03-14T21:42:17Z'
           readOnly: true
+          nullable: true
+          default: null
 
         updated_at:
           type: string
           format: date-time
           example: '2020-03-14T21:42:17Z'
           readOnly: true
+          nullable: true
+          default: null
diff --git a/tests/unit/Issue58FixTest.php b/tests/unit/Issue58FixTest.php
index f6c902b6..cb7ad1ec 100644
--- a/tests/unit/Issue58FixTest.php
+++ b/tests/unit/Issue58FixTest.php
@@ -831,13 +831,17 @@ public function test58MoveLast2Col2PosUp()
         id:
           type: integer
         colour:
-          type: boolean          
+          type: boolean
+          nullable: true          
         size:
           type: boolean
+          nullable: true
         name:
           type: boolean
+          nullable: true
         description:
-          type: boolean        
+          type: boolean 
+          nullable: true
 paths:
   '/':
     get:
@@ -895,14 +899,19 @@ public function test58Move1Add1Del1Col()
       properties:
         id:
           type: integer
+          nullable: true
         colour:
           type: boolean
+          nullable: true
         name:
           type: boolean
+          nullable: true
         description:
           type: boolean
+          nullable: true
         col_6:
           type: integer
+          nullable: true
 paths:
   '/':
     get:
@@ -963,13 +972,17 @@ public function test58Add1Del1ColAtSamePosition()
           type: integer
         name:
           type: boolean
+          nullable: true
         description_new:
           type: integer
           default: 7
+          nullable: true
         colour:
           type: boolean
+          nullable: true
         size:
           type: boolean
+          nullable: true
 paths:
   '/':
     get:
@@ -1028,14 +1041,19 @@ public function test58Add3Del2ColAtDiffPos()
           type: integer
         col_6:
           type: boolean
+          nullable: true
         name:
           type: boolean
+          nullable: true
         col_7:
           type: boolean
+          nullable: true
         col_8:
           type: boolean
+          nullable: true
         size:
           type: boolean
+          nullable: true
 paths:
   '/':
     get:
@@ -1163,15 +1181,20 @@ public function test58MoveAColAndChangeItsDataType()
       type: object
       properties:
         id:
-          type: integer        
+          type: integer
+          nullable: true
         description:
           type: boolean
+          nullable: true
         colour:
           type: integer
+          nullable: true
         name:
           type: boolean
+          nullable: true
         size:
           type: boolean
+          nullable: true
 paths:
   '/':
     get:
@@ -1230,12 +1253,16 @@ public function test58MoveAColDownwards()
           type: integer        
         description:
           type: boolean
+          nullable: true
         colour:
           type: boolean
+          nullable: true
         name:
           type: boolean
+          nullable: true
         size:
           type: boolean
+          nullable: true
 paths:
   '/':
     get:
@@ -1289,15 +1316,19 @@ public function test58MoveAColUpwards()
       type: object
       properties:
         id:
-          type: integer        
+          type: integer
         colour:
           type: boolean
+          nullable: true
         name:
           type: boolean
+          nullable: true
         description:
           type: boolean
+          nullable: true
         size:
           type: boolean
+          nullable: true
 paths:
   '/':
     get:
diff --git a/tests/unit/IssueFixTest.php b/tests/unit/IssueFixTest.php
index 20c2e2f1..55bc2a5c 100644
--- a/tests/unit/IssueFixTest.php
+++ b/tests/unit/IssueFixTest.php
@@ -170,7 +170,7 @@ public function testTimestampIssue143()
         ]);
 
         // check no files are generated
-        $this->assertEquals(count($actualFiles), 0);
+        $this->assertCount(0, $actualFiles);
         $this->deleteTables();
     }
 
@@ -716,12 +716,12 @@ private function createTableFor60DescriptionOfAProperty()
     {
         Yii::$app->db->createCommand()->createTable('{{%animals}}', [
             'id' => 'pk',
-            'name' => 'text ', # comment "the name"
-            'g' => 'text',
-            'g2' => 'text',
-            'g3' => 'text',
-            'g4' => 'text',
-            'drop_col' => 'text',
+            'name' => 'text not null', # comment "the name"
+            'g' => 'text not null',
+            'g2' => 'text not null',
+            'g3' => 'text not null',
+            'g4' => 'text not null',
+            'drop_col' => 'text not null',
         ])->execute();
 
         Yii::$app->db->createCommand()->addCommentOnColumn('{{%animals}}', 'name', 'the comment on name col')->execute();
@@ -757,9 +757,9 @@ private function createTestTableFor3BugAddRemovePropertyAndAtTheSameTimeChangeIt
     {
         Yii::$app->db->createCommand()->createTable('{{%addresses}}', [
             'id' => 'pk',
-            'name' => 'varchar(64)',
-            'shortName' => 'varchar(64)',
-            'postalCode' => 'varchar(64)',
+            'name' => 'varchar(64) not null',
+            'shortName' => 'varchar(64) not null',
+            'postalCode' => 'varchar(64) not null',
         ])->execute();
         Yii::$app->db->createCommand()->createIndex('addresses_shortName_postalCode_key', '{{%addresses}}', ["shortName", "postalCode"], true)->execute();
     }

From 60779f650c69d8c56f31195c9e89a7c344aa384a Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Mon, 10 Mar 2025 18:31:17 +0530
Subject: [PATCH 06/12] Change lot of tests 3 - Fix failing tests

---
 tests/migrations/m100000_000000_maria.php     |   2 +-
 .../m200000_000001_create_table_users.php     |   6 +-
 ...m200000_000002_create_table_blog_posts.php |   6 +-
 .../m200000_000003_create_table_fakerable.php |  28 ++--
 .../m200000_000001_create_table_users.php     |   6 +-
 ...m200000_000002_create_table_blog_posts.php |   6 +-
 .../m200000_000003_create_table_fakerable.php |  28 ++--
 tests/specs/blog_v2.yaml                      |   8 +
 .../m200000_000000_change_table_v2_posts.php  |   2 +-
 ...200000_000005_change_table_v2_comments.php |   2 +-
 .../m200000_000000_change_table_v2_posts.php  |   2 +-
 ...200000_000005_change_table_v2_comments.php |   6 +-
 .../m200000_000000_change_table_v2_posts.php  |   4 +-
 ...200000_000005_change_table_v2_comments.php |   2 +-
 ...200000_000000_change_table_v3_pgcustom.php |   8 +
 .../m200000_000000_create_table_c123s.php     |   2 +-
 .../m200000_000001_create_table_b123s.php     |   4 +-
 .../m200000_000002_create_table_a123s.php     |   4 +-
 .../m200000_000004_create_table_d123s.php     |   2 +-
 .../m200000_000006_create_table_e123s.php     |   4 +-
 .../m200000_000007_create_table_routings.php  |  12 +-
 ...m200000_000002_create_table_newcolumns.php |   8 +-
 ...000_000000_create_table_alldbdatatypes.php |  74 ++++----
 ...200000_000001_create_table_editcolumns.php |   8 +-
 ...m200000_000002_create_table_newcolumns.php |   8 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php |  74 ++++----
 ...200000_000001_create_table_editcolumns.php |   8 +-
 ...m200000_000002_create_table_newcolumns.php |   8 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php | 158 +++++++++---------
 ...200000_000001_create_table_editcolumns.php |   8 +-
 ...m200000_000002_create_table_newcolumns.php |  12 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php |  74 ++++----
 ...200000_000001_create_table_editcolumns.php |   8 +-
 ...m200000_000002_change_table_newcolumns.php |   8 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php |  74 ++++----
 ...200000_000001_create_table_editcolumns.php |   8 +-
 ...m200000_000002_change_table_newcolumns.php |   8 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php | 158 +++++++++---------
 ...200000_000001_create_table_editcolumns.php |   8 +-
 ...m200000_000002_change_table_newcolumns.php |  12 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 46 files changed, 497 insertions(+), 479 deletions(-)

diff --git a/tests/migrations/m100000_000000_maria.php b/tests/migrations/m100000_000000_maria.php
index 936f7c83..3b60c4a5 100644
--- a/tests/migrations/m100000_000000_maria.php
+++ b/tests/migrations/m100000_000000_maria.php
@@ -3,7 +3,7 @@
 use yii\db\Schema;
 
 /**
- * Initial migration for blog_v2 (based on blog.yaml), so result for blog_v2 should be as secondary mogration
+ * Initial migration for blog_v2 (based on blog.yaml), so result for blog_v2 should be as secondary migration
  **/
 class m100000_000000_maria extends Migration
 {
diff --git a/tests/specs/blog/migrations_mysql_db/m200000_000001_create_table_users.php b/tests/specs/blog/migrations_mysql_db/m200000_000001_create_table_users.php
index a90792e9..813b1c95 100644
--- a/tests/specs/blog/migrations_mysql_db/m200000_000001_create_table_users.php
+++ b/tests/specs/blog/migrations_mysql_db/m200000_000001_create_table_users.php
@@ -12,9 +12,9 @@ public function up()
             'username' => $this->string(200)->notNull(),
             'email' => $this->string(200)->notNull(),
             'password' => $this->string()->notNull(),
-            'role' => $this->string(20)->null()->defaultValue('reader'),
-            'flags' => $this->integer()->null()->defaultValue(0),
-            'created_at' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'role' => $this->string(20)->notNull()->defaultValue('reader'),
+            'flags' => $this->integer()->notNull()->defaultValue(0),
+            'created_at' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
         ]);
         $this->createIndex('users_username_key', '{{%users}}', 'username', true);
         $this->createIndex('users_email_key', '{{%users}}', 'email', true);
diff --git a/tests/specs/blog/migrations_mysql_db/m200000_000002_create_table_blog_posts.php b/tests/specs/blog/migrations_mysql_db/m200000_000002_create_table_blog_posts.php
index c7cc90fb..acb248b0 100644
--- a/tests/specs/blog/migrations_mysql_db/m200000_000002_create_table_blog_posts.php
+++ b/tests/specs/blog/migrations_mysql_db/m200000_000002_create_table_blog_posts.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%blog_posts}}', [
             0 => 'uid varchar(128) NOT NULL',
             'title' => $this->string(255)->notNull(),
-            'slug' => $this->string(200)->null()->defaultValue(null),
+            'slug' => $this->string(200)->notNull(),
             'category_id' => $this->integer()->notNull()->comment('Category of posts'),
             'active' => $this->boolean()->notNull()->defaultValue(false),
-            'created_at' => $this->date()->null()->defaultValue(null),
-            'created_by_id' => $this->integer()->null()->defaultValue(null)->comment('The User'),
+            'created_at' => $this->date()->notNull(),
+            'created_by_id' => $this->integer()->notNull()->comment('The User'),
         ]);
         $this->addPrimaryKey('pk_blog_posts_uid', '{{%blog_posts}}', 'uid');
         $this->createIndex('blog_posts_title_key', '{{%blog_posts}}', 'title', true);
diff --git a/tests/specs/blog/migrations_mysql_db/m200000_000003_create_table_fakerable.php b/tests/specs/blog/migrations_mysql_db/m200000_000003_create_table_fakerable.php
index 0f3eebad..bd7b21f4 100644
--- a/tests/specs/blog/migrations_mysql_db/m200000_000003_create_table_fakerable.php
+++ b/tests/specs/blog/migrations_mysql_db/m200000_000003_create_table_fakerable.php
@@ -9,20 +9,20 @@ public function up()
     {
         $this->createTable('{{%fakerable}}', [
             'id' => $this->bigPrimaryKey(),
-            'active' => $this->boolean()->null()->defaultValue(null),
-            'floatval' => $this->float()->null()->defaultValue(null),
-            'floatval_lim' => $this->float()->null()->defaultValue(null),
-            'doubleval' => $this->double()->null()->defaultValue(null),
-            'int_min' => $this->integer()->null()->defaultValue(3),
-            'int_max' => $this->integer()->null()->defaultValue(null),
-            'int_minmax' => $this->integer()->null()->defaultValue(null),
-            'int_created_at' => $this->integer()->null()->defaultValue(null),
-            'int_simple' => $this->integer()->null()->defaultValue(null),
-            'str_text' => $this->text()->null(),
-            'str_varchar' => $this->string(100)->null()->defaultValue(null),
-            'str_date' => $this->date()->null()->defaultValue(null),
-            'str_datetime' => $this->timestamp()->null()->defaultValue(null),
-            'str_country' => $this->text()->null(),
+            'active' => $this->boolean()->notNull(),
+            'floatval' => $this->float()->notNull(),
+            'floatval_lim' => $this->float()->notNull(),
+            'doubleval' => $this->double()->notNull(),
+            'int_min' => $this->integer()->notNull()->defaultValue(3),
+            'int_max' => $this->integer()->notNull(),
+            'int_minmax' => $this->integer()->notNull(),
+            'int_created_at' => $this->integer()->notNull(),
+            'int_simple' => $this->integer()->notNull(),
+            'str_text' => $this->text()->notNull(),
+            'str_varchar' => $this->string(100)->notNull(),
+            'str_date' => $this->date()->notNull(),
+            'str_datetime' => $this->timestamp()->notNull(),
+            'str_country' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/blog/migrations_pgsql_db/m200000_000001_create_table_users.php b/tests/specs/blog/migrations_pgsql_db/m200000_000001_create_table_users.php
index e2bc0165..c168edb2 100644
--- a/tests/specs/blog/migrations_pgsql_db/m200000_000001_create_table_users.php
+++ b/tests/specs/blog/migrations_pgsql_db/m200000_000001_create_table_users.php
@@ -12,9 +12,9 @@ public function safeUp()
             'username' => $this->string(200)->notNull(),
             'email' => $this->string(200)->notNull(),
             'password' => $this->string()->notNull(),
-            'role' => $this->string(20)->null()->defaultValue('reader'),
-            'flags' => $this->integer()->null()->defaultValue(0),
-            'created_at' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
+            'role' => $this->string(20)->notNull()->defaultValue('reader'),
+            'flags' => $this->integer()->notNull()->defaultValue(0),
+            'created_at' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
         ]);
         $this->createIndex('users_username_key', '{{%users}}', 'username', true);
         $this->createIndex('users_email_key', '{{%users}}', 'email', true);
diff --git a/tests/specs/blog/migrations_pgsql_db/m200000_000002_create_table_blog_posts.php b/tests/specs/blog/migrations_pgsql_db/m200000_000002_create_table_blog_posts.php
index 9dbe55cf..f15a44ac 100644
--- a/tests/specs/blog/migrations_pgsql_db/m200000_000002_create_table_blog_posts.php
+++ b/tests/specs/blog/migrations_pgsql_db/m200000_000002_create_table_blog_posts.php
@@ -10,11 +10,11 @@ public function safeUp()
         $this->createTable('{{%blog_posts}}', [
             0 => '"uid" varchar(128) NOT NULL',
             'title' => $this->string(255)->notNull(),
-            'slug' => $this->string(200)->null()->defaultValue(null),
+            'slug' => $this->string(200)->notNull(),
             'category_id' => $this->integer()->notNull()->comment('Category of posts'),
             'active' => $this->boolean()->notNull()->defaultValue(false),
-            'created_at' => $this->date()->null()->defaultValue(null),
-            'created_by_id' => $this->integer()->null()->defaultValue(null)->comment('The User'),
+            'created_at' => $this->date()->notNull(),
+            'created_by_id' => $this->integer()->notNull()->comment('The User'),
         ]);
         $this->addPrimaryKey('pk_blog_posts_uid', '{{%blog_posts}}', 'uid');
         $this->createIndex('blog_posts_title_key', '{{%blog_posts}}', 'title', true);
diff --git a/tests/specs/blog/migrations_pgsql_db/m200000_000003_create_table_fakerable.php b/tests/specs/blog/migrations_pgsql_db/m200000_000003_create_table_fakerable.php
index a42b8954..36aa6e6d 100644
--- a/tests/specs/blog/migrations_pgsql_db/m200000_000003_create_table_fakerable.php
+++ b/tests/specs/blog/migrations_pgsql_db/m200000_000003_create_table_fakerable.php
@@ -9,20 +9,20 @@ public function safeUp()
     {
         $this->createTable('{{%fakerable}}', [
             'id' => $this->bigPrimaryKey(),
-            'active' => $this->boolean()->null()->defaultValue(null),
-            'floatval' => $this->float()->null()->defaultValue(null),
-            'floatval_lim' => $this->float()->null()->defaultValue(null),
-            'doubleval' => $this->double()->null()->defaultValue(null),
-            'int_min' => $this->integer()->null()->defaultValue(3),
-            'int_max' => $this->integer()->null()->defaultValue(null),
-            'int_minmax' => $this->integer()->null()->defaultValue(null),
-            'int_created_at' => $this->integer()->null()->defaultValue(null),
-            'int_simple' => $this->integer()->null()->defaultValue(null),
-            'str_text' => $this->text()->null()->defaultValue(null),
-            'str_varchar' => $this->string(100)->null()->defaultValue(null),
-            'str_date' => $this->date()->null()->defaultValue(null),
-            'str_datetime' => $this->timestamp()->null()->defaultValue(null),
-            'str_country' => $this->text()->null()->defaultValue(null),
+            'active' => $this->boolean()->notNull(),
+            'floatval' => $this->float()->notNull(),
+            'floatval_lim' => $this->float()->notNull(),
+            'doubleval' => $this->double()->notNull(),
+            'int_min' => $this->integer()->notNull()->defaultValue(3),
+            'int_max' => $this->integer()->notNull(),
+            'int_minmax' => $this->integer()->notNull(),
+            'int_created_at' => $this->integer()->notNull(),
+            'int_simple' => $this->integer()->notNull(),
+            'str_text' => $this->text()->notNull(),
+            'str_varchar' => $this->string(100)->notNull(),
+            'str_date' => $this->date()->notNull(),
+            'str_datetime' => $this->timestamp()->notNull(),
+            'str_country' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/blog_v2.yaml b/tests/specs/blog_v2.yaml
index e4ab5a48..065c60ef 100644
--- a/tests/specs/blog_v2.yaml
+++ b/tests/specs/blog_v2.yaml
@@ -268,12 +268,15 @@ components:
             - editor
             - reader
           x-faker: "$faker->randomElement(['admin', 'editor', 'reader'])"
+          nullable: true
         flags:
           type: integer
           default: 0
+          nullable: true
         created_at:
           type: string
           format: date-time
+          nullable: true
     Users:
       type: array
       items:
@@ -332,12 +335,14 @@ components:
           type: string
           minLength: 1
           maxLength: 200
+          nullable: true
         lang:
           type: string
           enum:
             - ru
             - eng
           default: ru
+          nullable: true
         category:
           $ref: "#/components/schemas/Category"
         active:
@@ -345,6 +350,8 @@ components:
         created_at:
           type: string
           format: date
+          nullable: true
+          default: null
         created_by:
           $ref: "#/components/schemas/User"
         comments:
@@ -384,6 +391,7 @@ components:
           minLength: 1
           maxLength: 300
           default: ''
+          nullable: true
         created_at:
           type: string
           format: date-time
diff --git a/tests/specs/blog_v2/migrations_maria_db/m200000_000000_change_table_v2_posts.php b/tests/specs/blog_v2/migrations_maria_db/m200000_000000_change_table_v2_posts.php
index 5f50d0d7..f1363c2a 100644
--- a/tests/specs/blog_v2/migrations_maria_db/m200000_000000_change_table_v2_posts.php
+++ b/tests/specs/blog_v2/migrations_maria_db/m200000_000000_change_table_v2_posts.php
@@ -13,7 +13,7 @@ public function up()
         $this->dropColumn('{{%v2_posts}}', 'uid');
         $this->alterColumn('{{%v2_posts}}', 'category_id', $this->bigInteger()->notNull());
         $this->alterColumn('{{%v2_posts}}', 'active', $this->tinyInteger(1)->notNull());
-        $this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->null()->defaultValue(null));
+        $this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->notNull());
     }
 
     public function down()
diff --git a/tests/specs/blog_v2/migrations_maria_db/m200000_000005_change_table_v2_comments.php b/tests/specs/blog_v2/migrations_maria_db/m200000_000005_change_table_v2_comments.php
index b34a7810..32251d30 100644
--- a/tests/specs/blog_v2/migrations_maria_db/m200000_000005_change_table_v2_comments.php
+++ b/tests/specs/blog_v2/migrations_maria_db/m200000_000005_change_table_v2_comments.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');
         $this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
-        $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->after('post_id')->comment('The User'));
+        $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->notNull()->after('post_id')->comment('The User'));
         $this->dropColumn('{{%v2_comments}}', 'author_id');
         $this->alterColumn('{{%v2_comments}}', 'message', $this->text()->notNull());
         $this->alterColumn('{{%v2_comments}}', 'meta_data', $this->string(300)->null()->defaultValue(''));
diff --git a/tests/specs/blog_v2/migrations_mysql_db/m200000_000000_change_table_v2_posts.php b/tests/specs/blog_v2/migrations_mysql_db/m200000_000000_change_table_v2_posts.php
index eea03cca..9bdaffa6 100644
--- a/tests/specs/blog_v2/migrations_mysql_db/m200000_000000_change_table_v2_posts.php
+++ b/tests/specs/blog_v2/migrations_mysql_db/m200000_000000_change_table_v2_posts.php
@@ -13,7 +13,7 @@ public function up()
         $this->dropColumn('{{%v2_posts}}', 'uid');
         $this->alterColumn('{{%v2_posts}}', 'category_id', $this->bigInteger()->notNull());
         $this->alterColumn('{{%v2_posts}}', 'active', $this->tinyInteger(1)->notNull());
-        $this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->null()->defaultValue(null));
+        $this->alterColumn('{{%v2_posts}}', 'created_by_id', $this->bigInteger()->notNull());
     }
 
     public function down()
diff --git a/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php b/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
index 8ac91b71..b74e6258 100644
--- a/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
+++ b/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
@@ -7,9 +7,9 @@ class m200000_000005_change_table_v2_comments extends \yii\db\Migration
 {
     public function up()
     {
-        $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');
         $this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
-        $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->after('post_id')->comment('The User'));
+        $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');
+        $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->notNull()->after('post_id')->comment('The User'));
         $this->dropColumn('{{%v2_comments}}', 'author_id');
         $this->alterColumn('{{%v2_comments}}', 'message', $this->text()->notNull());
         $this->alterColumn('{{%v2_comments}}', 'meta_data', $this->string(300)->null()->defaultValue(''));
@@ -27,7 +27,7 @@ public function down()
         $this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL');
         $this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull()->after('post_id'));
         $this->dropColumn('{{%v2_comments}}', 'user_id');
-        $this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'author_id', 'itt_v2_users', 'id');
         $this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'post_id', 'itt_v2_posts', 'uid');
+        $this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'author_id', 'itt_v2_users', 'id');
     }
 }
diff --git a/tests/specs/blog_v2/migrations_pgsql_db/m200000_000000_change_table_v2_posts.php b/tests/specs/blog_v2/migrations_pgsql_db/m200000_000000_change_table_v2_posts.php
index 9444aef9..c2adc36d 100644
--- a/tests/specs/blog_v2/migrations_pgsql_db/m200000_000000_change_table_v2_posts.php
+++ b/tests/specs/blog_v2/migrations_pgsql_db/m200000_000000_change_table_v2_posts.php
@@ -14,7 +14,8 @@ public function safeUp()
         $this->dropColumn('{{%v2_posts}}', 'uid');
         $this->alterColumn('{{%v2_posts}}', 'category_id', 'int8 NOT NULL USING "category_id"::int8');
         $this->alterColumn('{{%v2_posts}}', 'active', "DROP DEFAULT");
-        $this->alterColumn('{{%v2_posts}}', 'created_by_id', 'int8 NULL USING "created_by_id"::int8');
+        $this->alterColumn('{{%v2_posts}}', 'created_by_id', 'int8 NOT NULL USING "created_by_id"::int8');
+        $this->alterColumn('{{%v2_posts}}', 'created_by_id', "SET NOT NULL");
     }
 
     public function safeDown()
@@ -27,5 +28,6 @@ public function safeDown()
         $this->dropColumn('{{%v2_posts}}', 'id');
         $this->execute('DROP TYPE "enum_itt_v2_posts_lang"');
         $this->alterColumn('{{%v2_posts}}', 'active', "SET DEFAULT 'f'");
+        $this->alterColumn('{{%v2_posts}}', 'created_by_id', "DROP NOT NULL");
     }
 }
diff --git a/tests/specs/blog_v2/migrations_pgsql_db/m200000_000005_change_table_v2_comments.php b/tests/specs/blog_v2/migrations_pgsql_db/m200000_000005_change_table_v2_comments.php
index e9ad9ff5..43b01b9b 100644
--- a/tests/specs/blog_v2/migrations_pgsql_db/m200000_000005_change_table_v2_comments.php
+++ b/tests/specs/blog_v2/migrations_pgsql_db/m200000_000005_change_table_v2_comments.php
@@ -9,7 +9,7 @@ public function safeUp()
     {
         $this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
         $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');
-        $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->null()->defaultValue(null)->comment('The User'));
+        $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->notNull()->comment('The User'));
         $this->dropColumn('{{%v2_comments}}', 'author_id');
         $this->alterColumn('{{%v2_comments}}', 'message', 'text NOT NULL USING "message"::text');
         $this->alterColumn('{{%v2_comments}}', 'message', "DROP DEFAULT");
diff --git a/tests/specs/postgres_custom/migrations_pgsql_db/m200000_000000_change_table_v3_pgcustom.php b/tests/specs/postgres_custom/migrations_pgsql_db/m200000_000000_change_table_v3_pgcustom.php
index 1356f456..3010acb1 100644
--- a/tests/specs/postgres_custom/migrations_pgsql_db/m200000_000000_change_table_v3_pgcustom.php
+++ b/tests/specs/postgres_custom/migrations_pgsql_db/m200000_000000_change_table_v3_pgcustom.php
@@ -8,6 +8,7 @@ class m200000_000000_change_table_v3_pgcustom extends \yii\db\Migration
     public function safeUp()
     {
         $this->createIndex('v3_pgcustom_search_gin_index', '{{%v3_pgcustom}}', 'to_tsvector(\'english\', search::text)', 'gin');
+        $this->alterColumn('{{%v3_pgcustom}}', 'num', "SET NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'json1', "SET NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'json1', "SET DEFAULT '[]'");
         $this->alterColumn('{{%v3_pgcustom}}', 'json2', "SET NOT NULL");
@@ -16,13 +17,17 @@ public function safeUp()
         $this->alterColumn('{{%v3_pgcustom}}', 'json3', "SET DEFAULT '[{\"foo\":\"foobar\"},{\"xxx\":\"yyy\"}]'");
         $this->alterColumn('{{%v3_pgcustom}}', 'json4', "SET NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'json4', "SET DEFAULT '{\"foo\":\"bar\",\"bar\":\"baz\"}'");
+        $this->alterColumn('{{%v3_pgcustom}}', 'status', "SET NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'status', "SET DEFAULT 'draft'");
+        $this->alterColumn('{{%v3_pgcustom}}', 'status_x', "SET NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'status_x', "SET DEFAULT 'draft'");
+        $this->alterColumn('{{%v3_pgcustom}}', 'search', "SET NOT NULL");
     }
 
     public function safeDown()
     {
         $this->dropIndex('v3_pgcustom_search_gin_index', '{{%v3_pgcustom}}');
+        $this->alterColumn('{{%v3_pgcustom}}', 'num', "DROP NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'json1', "DROP NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'json1', "DROP DEFAULT");
         $this->alterColumn('{{%v3_pgcustom}}', 'json2', "DROP NOT NULL");
@@ -31,7 +36,10 @@ public function safeDown()
         $this->alterColumn('{{%v3_pgcustom}}', 'json3', "SET DEFAULT '{\"bar\":\"baz\",\"foo\":\"bar\"}'");
         $this->alterColumn('{{%v3_pgcustom}}', 'json4', "DROP NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'json4', "SET DEFAULT '{\"ffo\":\"bar\"}'");
+        $this->alterColumn('{{%v3_pgcustom}}', 'status', "DROP NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'status', "DROP DEFAULT");
+        $this->alterColumn('{{%v3_pgcustom}}', 'status_x', "DROP NOT NULL");
         $this->alterColumn('{{%v3_pgcustom}}', 'status_x', "DROP DEFAULT");
+        $this->alterColumn('{{%v3_pgcustom}}', 'search', "DROP NOT NULL");
     }
 }
diff --git a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000000_create_table_c123s.php b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000000_create_table_c123s.php
index 0c9c1c80..141d9842 100644
--- a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000000_create_table_c123s.php
+++ b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000000_create_table_c123s.php
@@ -9,7 +9,7 @@ public function safeUp()
     {
         $this->createTable('{{%c123s}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null),
+            'name' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000001_create_table_b123s.php b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000001_create_table_b123s.php
index 688d4e58..f3921a7b 100644
--- a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000001_create_table_b123s.php
+++ b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000001_create_table_b123s.php
@@ -9,8 +9,8 @@ public function safeUp()
     {
         $this->createTable('{{%b123s}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null),
-            'c123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
+            'name' => $this->text()->notNull(),
+            'c123_id' => $this->integer()->notNull()->comment('desc'),
         ]);
         $this->addForeignKey('fk_b123s_c123_id_c123s_id', '{{%b123s}}', 'c123_id', '{{%c123s}}', 'id');
         $this->addCommentOnColumn('{{%b123s}}', 'c123_id', 'desc');
diff --git a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000002_create_table_a123s.php b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000002_create_table_a123s.php
index f93343c6..49957f33 100644
--- a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000002_create_table_a123s.php
+++ b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000002_create_table_a123s.php
@@ -9,8 +9,8 @@ public function safeUp()
     {
         $this->createTable('{{%a123s}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null),
-            'b123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
+            'name' => $this->text()->notNull(),
+            'b123_id' => $this->integer()->notNull()->comment('desc'),
         ]);
         $this->addForeignKey('fk_a123s_b123_id_b123s_id', '{{%a123s}}', 'b123_id', '{{%b123s}}', 'id');
         $this->addCommentOnColumn('{{%a123s}}', 'b123_id', 'desc');
diff --git a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000004_create_table_d123s.php b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000004_create_table_d123s.php
index 794186a8..81fd1431 100644
--- a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000004_create_table_d123s.php
+++ b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000004_create_table_d123s.php
@@ -9,7 +9,7 @@ public function safeUp()
     {
         $this->createTable('{{%d123s}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null),
+            'name' => $this->text()->notNull(),
         ]);
     }
 
diff --git a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000006_create_table_e123s.php b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000006_create_table_e123s.php
index 55cb62af..9d3fccf7 100644
--- a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000006_create_table_e123s.php
+++ b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000006_create_table_e123s.php
@@ -9,8 +9,8 @@ public function safeUp()
     {
         $this->createTable('{{%e123s}}', [
             'id' => $this->primaryKey(),
-            'name' => $this->text()->null()->defaultValue(null),
-            'b123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
+            'name' => $this->text()->notNull(),
+            'b123_id' => $this->integer()->notNull()->comment('desc'),
         ]);
         $this->addForeignKey('fk_e123s_b123_id_b123s_id', '{{%e123s}}', 'b123_id', '{{%b123s}}', 'id');
         $this->addCommentOnColumn('{{%e123s}}', 'b123_id', 'desc');
diff --git a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000007_create_table_routings.php b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000007_create_table_routings.php
index bd09ae48..df77676b 100644
--- a/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000007_create_table_routings.php
+++ b/tests/specs/relations_in_faker/app/migrations_pgsql_db/m200000_000007_create_table_routings.php
@@ -10,13 +10,13 @@ public function safeUp()
         $this->createTable('{{%routings}}', [
             'id' => $this->primaryKey(),
             'domain_id' => $this->integer()->notNull()->comment('domain'),
-            'path' => $this->string(255)->null()->defaultValue(null),
-            'ssl' => $this->boolean()->null()->defaultValue(null),
-            'redirect_to_ssl' => $this->boolean()->null()->defaultValue(null),
-            'service' => $this->string(255)->null()->defaultValue(null),
+            'path' => $this->string(255)->notNull(),
+            'ssl' => $this->boolean()->notNull(),
+            'redirect_to_ssl' => $this->boolean()->notNull(),
+            'service' => $this->string(255)->notNull(),
             0 => '"created_at" timestamp NULL DEFAULT NULL',
-            'd123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
-            'a123_id' => $this->integer()->null()->defaultValue(null)->comment('desc'),
+            'd123_id' => $this->integer()->notNull()->comment('desc'),
+            'a123_id' => $this->integer()->notNull()->comment('desc'),
         ]);
         $this->addForeignKey('fk_routings_domain_id_domains_id', '{{%routings}}', 'domain_id', '{{%domains}}', 'id');
         $this->addForeignKey('fk_routings_d123_id_d123s_id', '{{%routings}}', 'd123_id', '{{%d123s}}', 'id');
diff --git a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php
index aacd206c..f8dd75ca 100644
--- a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php
+++ b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%newcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL',
-            'last_name' => $this->text()->null(),
-            1 => 'dec_col decimal(12,4) NULL DEFAULT NULL',
+            'last_name' => $this->text()->notNull(),
+            1 => 'dec_col decimal(12,4) NOT NULL',
             2 => 'json_col json NOT NULL',
-            3 => 'varchar_col varchar(5) NULL DEFAULT NULL',
-            4 => 'numeric_col double precision NULL DEFAULT NULL',
+            3 => 'varchar_col varchar(5) NOT NULL',
+            4 => 'numeric_col double precision NOT NULL',
             5 => 'json_col_def_n json NOT NULL',
         ]);
     }
diff --git a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
index 9c002bea..44ad30b2 100644
--- a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,48 +9,48 @@ public function up()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => 'string_col varchar(255) NULL DEFAULT NULL',
-            1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
-            2 => 'text_col text NULL DEFAULT NULL',
-            3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
-            4 => 'char_4_col char(4) NULL DEFAULT NULL',
-            5 => 'char_5_col char NULL DEFAULT NULL',
+            0 => 'string_col varchar(255) NOT NULL',
+            1 => 'varchar_col varchar(132) NOT NULL',
+            2 => 'text_col text NOT NULL',
+            3 => 'varchar_4_col varchar(4) NOT NULL',
+            4 => 'char_4_col char(4) NOT NULL',
+            5 => 'char_5_col char NOT NULL',
             6 => 'char_6_col char NOT NULL',
             7 => 'char_7_col char(6) NOT NULL',
-            8 => 'char_8_col char NULL DEFAULT \'d\'',
-            9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
-            10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
-            11 => 'blob_col blob NULL DEFAULT NULL',
-            12 => 'bit_col bit NULL DEFAULT NULL',
-            13 => 'bit_2 bit(1) NULL DEFAULT NULL',
-            14 => 'bit_3 bit(64) NULL DEFAULT NULL',
-            15 => 'ti tinyint NULL DEFAULT NULL',
-            16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
-            17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
-            18 => 'si_col smallint NULL DEFAULT NULL',
-            19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
-            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
-            21 => 'bi bigint NULL DEFAULT NULL',
-            22 => 'int_col int NULL DEFAULT NULL',
-            23 => 'int_col_2 integer NULL DEFAULT NULL',
-            24 => 'numeric_col numeric NULL DEFAULT NULL',
-            25 => 'float_col float NULL DEFAULT NULL',
-            26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
-            27 => 'float_3 float(8) NULL DEFAULT NULL',
-            28 => 'double_col double NULL DEFAULT NULL',
-            29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
-            30 => 'double_p_2 double precision NULL DEFAULT NULL',
-            31 => 'real_col real NULL DEFAULT NULL',
-            32 => 'date_col date NULL DEFAULT NULL',
-            33 => 'time_col time NULL DEFAULT NULL',
-            34 => 'datetime_col datetime NULL DEFAULT NULL',
-            35 => 'timestamp_col timestamp NULL DEFAULT NULL',
-            36 => 'year_col year NULL DEFAULT NULL',
+            8 => 'char_8_col char NOT NULL DEFAULT \'d\'',
+            9 => 'decimal_col decimal(12,3) NOT NULL',
+            10 => 'varbinary_col varbinary(5) NOT NULL',
+            11 => 'blob_col blob NOT NULL',
+            12 => 'bit_col bit NOT NULL',
+            13 => 'bit_2 bit(1) NOT NULL',
+            14 => 'bit_3 bit(64) NOT NULL',
+            15 => 'ti tinyint NOT NULL',
+            16 => 'ti_2 tinyint(1) NOT NULL',
+            17 => 'ti_3 tinyint(2) NOT NULL',
+            18 => 'si_col smallint NOT NULL',
+            19 => 'si_col_2 smallint unsigned zerofill NOT NULL',
+            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NOT NULL DEFAULT 7',
+            21 => 'bi bigint NOT NULL',
+            22 => 'int_col int NOT NULL',
+            23 => 'int_col_2 integer NOT NULL',
+            24 => 'numeric_col numeric NOT NULL',
+            25 => 'float_col float NOT NULL',
+            26 => 'float_2 float(10, 2) NOT NULL',
+            27 => 'float_3 float(8) NOT NULL',
+            28 => 'double_col double NOT NULL',
+            29 => 'double_p double precision(10,2) NOT NULL',
+            30 => 'double_p_2 double precision NOT NULL',
+            31 => 'real_col real NOT NULL',
+            32 => 'date_col date NOT NULL',
+            33 => 'time_col time NOT NULL',
+            34 => 'datetime_col datetime NOT NULL',
+            35 => 'timestamp_col timestamp NOT NULL',
+            36 => 'year_col year NOT NULL',
             37 => 'json_col json NOT NULL',
             38 => 'json_col_def json NOT NULL DEFAULT \'[]\'',
             39 => 'json_col_def_2 json NOT NULL DEFAULT \'[]\'',
-            40 => 'blob_def blob NULL DEFAULT \'the blob\'',
-            41 => 'text_def text NULL DEFAULT \'the text\'',
+            40 => 'blob_def blob NOT NULL DEFAULT \'the blob\'',
+            41 => 'text_def text NOT NULL DEFAULT \'the text\'',
             42 => 'json_def json NOT NULL DEFAULT \'{"a":"b"}\'',
         ]);
     }
diff --git a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
index 1de3d8d5..4c649990 100644
--- a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
@@ -10,14 +10,14 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->null()->defaultValue(null),
-            1 => 'first_name varchar(255) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
-            2 => 'dec_col decimal(12,2) NULL DEFAULT 3.14',
+            2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
             3 => 'str_col_def varchar(3) NOT NULL',
             4 => 'json_col text NOT NULL DEFAULT \'fox jumps over dog\'',
             5 => 'json_col_2 json NOT NULL DEFAULT \'[]\'',
-            6 => 'numeric_col double precision NULL DEFAULT NULL',
+            6 => 'numeric_col double precision NOT NULL',
             7 => 'json_col_def_n json NOT NULL DEFAULT \'[]\'',
             8 => 'json_col_def_n_2 json NOT NULL DEFAULT \'[]\'',
         ]);
diff --git a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php
index a53b1995..e14e1be4 100644
--- a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php
+++ b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%newcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL',
-            'last_name' => $this->text()->null()->defaultValue(null),
-            1 => 'dec_col decimal(12,4) NULL DEFAULT NULL',
+            'last_name' => $this->text()->notNull(),
+            1 => 'dec_col decimal(12,4) NOT NULL',
             2 => 'json_col json NOT NULL',
-            3 => 'varchar_col varchar(5) NULL DEFAULT NULL',
-            4 => 'numeric_col double precision NULL DEFAULT NULL',
+            3 => 'varchar_col varchar(5) NOT NULL',
+            4 => 'numeric_col double precision NOT NULL',
             5 => 'json_col_def_n json NOT NULL DEFAULT \'[]\'',
         ]);
     }
diff --git a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
index 7c0b936f..746b4549 100644
--- a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function up()
         $this->createTable('{{%pristines}}', [
             0 => 'custom_id_col integer primary key auto_increment NOT NULL',
             1 => 'name text NOT NULL',
-            'tag' => $this->text()->null()->defaultValue('4 leg'),
-            2 => 'new_col varchar(17) NULL DEFAULT NULL',
-            3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
-            4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
-            5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull()->defaultValue('4 leg'),
+            2 => 'new_col varchar(17) NOT NULL',
+            3 => 'col_5 decimal(12,4) NOT NULL',
+            4 => 'col_6 decimal(11,2) NOT NULL',
+            5 => 'col_7 decimal(10,2) NOT NULL',
             6 => 'col_8 json NOT NULL',
-            7 => 'col_9 varchar(9) NULL DEFAULT NULL',
-            8 => 'col_10 varchar(10) NULL DEFAULT NULL',
-            9 => 'col_11 text NULL DEFAULT NULL',
-            10 => 'price decimal(10,2) NULL DEFAULT 0 COMMENT \'price in EUR\'',
+            7 => 'col_9 varchar(9) NOT NULL',
+            8 => 'col_10 varchar(10) NOT NULL',
+            9 => 'col_11 text NOT NULL',
+            10 => 'price decimal(10,2) NOT NULL DEFAULT 0 COMMENT \'price in EUR\'',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
index 2cda660f..6dfa9ea3 100644
--- a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,48 +9,48 @@ public function up()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => 'string_col varchar(255) NULL DEFAULT NULL',
-            1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
-            2 => 'text_col text NULL',
-            3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
-            4 => 'char_4_col char(4) NULL DEFAULT NULL',
-            5 => 'char_5_col char NULL DEFAULT NULL',
+            0 => 'string_col varchar(255) NOT NULL',
+            1 => 'varchar_col varchar(132) NOT NULL',
+            2 => 'text_col text NOT NULL',
+            3 => 'varchar_4_col varchar(4) NOT NULL',
+            4 => 'char_4_col char(4) NOT NULL',
+            5 => 'char_5_col char NOT NULL',
             6 => 'char_6_col char NOT NULL',
             7 => 'char_7_col char(6) NOT NULL',
-            8 => 'char_8_col char NULL DEFAULT \'d\'',
-            9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
-            10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
-            11 => 'blob_col blob NULL',
-            12 => 'bit_col bit NULL DEFAULT NULL',
-            13 => 'bit_2 bit(1) NULL DEFAULT NULL',
-            14 => 'bit_3 bit(64) NULL DEFAULT NULL',
-            15 => 'ti tinyint NULL DEFAULT NULL',
-            16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
-            17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
-            18 => 'si_col smallint NULL DEFAULT NULL',
-            19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
-            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
-            21 => 'bi bigint NULL DEFAULT NULL',
-            22 => 'int_col int NULL DEFAULT NULL',
-            23 => 'int_col_2 integer NULL DEFAULT NULL',
-            24 => 'numeric_col numeric NULL DEFAULT NULL',
-            25 => 'float_col float NULL DEFAULT NULL',
-            26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
-            27 => 'float_3 float(8) NULL DEFAULT NULL',
-            28 => 'double_col double NULL DEFAULT NULL',
-            29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
-            30 => 'double_p_2 double precision NULL DEFAULT NULL',
-            31 => 'real_col real NULL DEFAULT NULL',
-            32 => 'date_col date NULL DEFAULT NULL',
-            33 => 'time_col time NULL DEFAULT NULL',
-            34 => 'datetime_col datetime NULL DEFAULT NULL',
-            35 => 'timestamp_col timestamp NULL DEFAULT NULL',
-            36 => 'year_col year NULL DEFAULT NULL',
+            8 => 'char_8_col char NOT NULL DEFAULT \'d\'',
+            9 => 'decimal_col decimal(12,3) NOT NULL',
+            10 => 'varbinary_col varbinary(5) NOT NULL',
+            11 => 'blob_col blob NOT NULL',
+            12 => 'bit_col bit NOT NULL',
+            13 => 'bit_2 bit(1) NOT NULL',
+            14 => 'bit_3 bit(64) NOT NULL',
+            15 => 'ti tinyint NOT NULL',
+            16 => 'ti_2 tinyint(1) NOT NULL',
+            17 => 'ti_3 tinyint(2) NOT NULL',
+            18 => 'si_col smallint NOT NULL',
+            19 => 'si_col_2 smallint unsigned zerofill NOT NULL',
+            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NOT NULL DEFAULT 7',
+            21 => 'bi bigint NOT NULL',
+            22 => 'int_col int NOT NULL',
+            23 => 'int_col_2 integer NOT NULL',
+            24 => 'numeric_col numeric NOT NULL',
+            25 => 'float_col float NOT NULL',
+            26 => 'float_2 float(10, 2) NOT NULL',
+            27 => 'float_3 float(8) NOT NULL',
+            28 => 'double_col double NOT NULL',
+            29 => 'double_p double precision(10,2) NOT NULL',
+            30 => 'double_p_2 double precision NOT NULL',
+            31 => 'real_col real NOT NULL',
+            32 => 'date_col date NOT NULL',
+            33 => 'time_col time NOT NULL',
+            34 => 'datetime_col datetime NOT NULL',
+            35 => 'timestamp_col timestamp NOT NULL',
+            36 => 'year_col year NOT NULL',
             37 => 'json_col json NOT NULL',
             38 => 'json_col_def json NOT NULL',
             39 => 'json_col_def_2 json NOT NULL',
-            40 => 'blob_def blob NULL',
-            41 => 'text_def text NULL',
+            40 => 'blob_def blob NOT NULL',
+            41 => 'text_def text NOT NULL',
             42 => 'json_def json NOT NULL',
         ]);
     }
diff --git a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
index 8c84e731..15954d2a 100644
--- a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
@@ -10,14 +10,14 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->null(),
-            1 => 'first_name varchar(255) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null(),
-            2 => 'dec_col decimal(12,2) NULL DEFAULT 3.14',
+            2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
             3 => 'str_col_def varchar(3) NOT NULL',
             4 => 'json_col text NOT NULL',
             5 => 'json_col_2 json NOT NULL',
-            6 => 'numeric_col double precision NULL DEFAULT NULL',
+            6 => 'numeric_col double precision NOT NULL',
             7 => 'json_col_def_n json NOT NULL',
             8 => 'json_col_def_n_2 json NOT NULL',
         ]);
diff --git a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php
index aacd206c..f8dd75ca 100644
--- a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php
+++ b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000002_create_table_newcolumns.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%newcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL',
-            'last_name' => $this->text()->null(),
-            1 => 'dec_col decimal(12,4) NULL DEFAULT NULL',
+            'last_name' => $this->text()->notNull(),
+            1 => 'dec_col decimal(12,4) NOT NULL',
             2 => 'json_col json NOT NULL',
-            3 => 'varchar_col varchar(5) NULL DEFAULT NULL',
-            4 => 'numeric_col double precision NULL DEFAULT NULL',
+            3 => 'varchar_col varchar(5) NOT NULL',
+            4 => 'numeric_col double precision NOT NULL',
             5 => 'json_col_def_n json NOT NULL',
         ]);
     }
diff --git a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
index 50881e9d..96f3acdc 100644
--- a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function up()
         $this->createTable('{{%pristines}}', [
             0 => 'custom_id_col integer primary key auto_increment NOT NULL',
             1 => 'name text NOT NULL',
-            'tag' => $this->text()->null(),
-            2 => 'new_col varchar(17) NULL DEFAULT NULL',
-            3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
-            4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
-            5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            2 => 'new_col varchar(17) NOT NULL',
+            3 => 'col_5 decimal(12,4) NOT NULL',
+            4 => 'col_6 decimal(11,2) NOT NULL',
+            5 => 'col_7 decimal(10,2) NOT NULL',
             6 => 'col_8 json NOT NULL',
-            7 => 'col_9 varchar(9) NULL DEFAULT NULL',
-            8 => 'col_10 varchar(10) NULL DEFAULT NULL',
-            9 => 'col_11 text NULL',
-            10 => 'price decimal(10,2) NULL DEFAULT 0 COMMENT \'price in EUR\'',
+            7 => 'col_9 varchar(9) NOT NULL',
+            8 => 'col_10 varchar(10) NOT NULL',
+            9 => 'col_11 text NOT NULL',
+            10 => 'price decimal(10,2) NOT NULL DEFAULT 0 COMMENT \'price in EUR\'',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
index e0cac52a..b3239c59 100644
--- a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,99 +9,99 @@ public function safeUp()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => '"string_col" varchar NULL DEFAULT NULL',
-            1 => '"varchar_col" varchar NULL DEFAULT NULL',
-            2 => '"text_col" text NULL DEFAULT NULL',
-            3 => '"text_col_array" text[] NULL DEFAULT NULL',
-            4 => '"varchar_4_col" varchar(4) NULL DEFAULT NULL',
-            5 => '"varchar_5_col" varchar(5) NULL DEFAULT NULL',
-            6 => '"char_4_col" char(4) NULL DEFAULT NULL',
-            7 => '"char_5_col" char NULL DEFAULT NULL',
+            0 => '"string_col" varchar NOT NULL',
+            1 => '"varchar_col" varchar NOT NULL',
+            2 => '"text_col" text NOT NULL',
+            3 => '"text_col_array" text[] NOT NULL',
+            4 => '"varchar_4_col" varchar(4) NOT NULL',
+            5 => '"varchar_5_col" varchar(5) NOT NULL',
+            6 => '"char_4_col" char(4) NOT NULL',
+            7 => '"char_5_col" char NOT NULL',
             8 => '"char_6_col" char NOT NULL',
             9 => '"char_7_col" char(6) NOT NULL',
-            10 => '"char_8_col" char NULL DEFAULT \'d\'',
-            11 => '"decimal_col" decimal(12,3) NULL DEFAULT NULL',
-            12 => '"bytea_col_2" bytea NULL DEFAULT NULL',
-            13 => '"bit_col" bit NULL DEFAULT NULL',
-            14 => '"bit_2" bit(1) NULL DEFAULT NULL',
-            15 => '"bit_3" bit(64) NULL DEFAULT NULL',
-            16 => '"ti" smallint NULL DEFAULT NULL',
-            17 => '"int2_col" int2 NULL DEFAULT NULL',
+            10 => '"char_8_col" char NOT NULL DEFAULT \'d\'',
+            11 => '"decimal_col" decimal(12,3) NOT NULL',
+            12 => '"bytea_col_2" bytea NOT NULL',
+            13 => '"bit_col" bit NOT NULL',
+            14 => '"bit_2" bit(1) NOT NULL',
+            15 => '"bit_3" bit(64) NOT NULL',
+            16 => '"ti" smallint NOT NULL',
+            17 => '"int2_col" int2 NOT NULL',
             18 => '"smallserial_col" smallserial NOT NULL',
             19 => '"serial2_col" serial2 NOT NULL',
-            20 => '"si_col" smallint NULL DEFAULT NULL',
-            21 => '"si_col_2" smallint NULL DEFAULT NULL',
-            22 => '"bi" bigint NULL DEFAULT NULL',
-            23 => '"bi2" int8 NULL DEFAULT NULL',
-            24 => '"int4_col" int4 NULL DEFAULT NULL',
+            20 => '"si_col" smallint NOT NULL',
+            21 => '"si_col_2" smallint NOT NULL',
+            22 => '"bi" bigint NOT NULL',
+            23 => '"bi2" int8 NOT NULL',
+            24 => '"int4_col" int4 NOT NULL',
             25 => '"bigserial_col" bigserial NOT NULL',
             26 => '"bigserial_col_2" serial8 NOT NULL',
-            27 => '"int_col" int NULL DEFAULT NULL',
-            28 => '"int_col_2" integer NULL DEFAULT NULL',
-            29 => '"numeric_col" numeric NULL DEFAULT NULL',
-            30 => '"numeric_col_2" numeric(10) NULL DEFAULT NULL',
-            31 => '"numeric_col_3" numeric(10,2) NULL DEFAULT NULL',
-            32 => '"double_p_2" double precision NULL DEFAULT NULL',
-            33 => '"double_p_3" double precision NULL DEFAULT NULL',
-            34 => '"real_col" real NULL DEFAULT NULL',
-            35 => '"float4_col" float4 NULL DEFAULT NULL',
-            36 => '"date_col" date NULL DEFAULT NULL',
-            37 => '"time_col" time NULL DEFAULT NULL',
-            38 => '"time_col_2" time with time zone NULL DEFAULT NULL',
-            39 => '"time_col_3" time without time zone NULL DEFAULT NULL',
-            40 => '"time_col_4" time(3) without time zone NULL DEFAULT NULL',
-            41 => '"timetz_col" timetz NULL DEFAULT NULL',
-            42 => '"timetz_col_2" timetz(3) NULL DEFAULT NULL',
-            43 => '"timestamp_col" timestamp NULL DEFAULT NULL',
-            44 => '"timestamp_col_2" timestamp with time zone NULL DEFAULT NULL',
-            45 => '"timestamp_col_3" timestamp without time zone NULL DEFAULT NULL',
-            46 => '"timestamp_col_4" timestamp(3) without time zone NULL DEFAULT NULL',
-            47 => '"timestamptz_col" timestamptz NULL DEFAULT NULL',
-            48 => '"timestamptz_col_2" timestamptz(3) NULL DEFAULT NULL',
-            49 => '"date2" date NULL DEFAULT NULL',
-            50 => '"timestamp_col_z" timestamp NULL DEFAULT NULL',
-            51 => '"bit_varying" bit varying NULL DEFAULT NULL',
-            52 => '"bit_varying_n" bit varying(8) NULL DEFAULT NULL',
-            53 => '"bit_varying_n_2" varbit NULL DEFAULT NULL',
-            54 => '"bit_varying_n_3" varbit(3) NULL DEFAULT NULL',
-            55 => '"bool_col" boolean NULL DEFAULT NULL',
-            56 => '"bool_col_2" bool NULL DEFAULT NULL',
-            57 => '"box_col" box NULL DEFAULT NULL',
-            58 => '"character_col" character NULL DEFAULT NULL',
-            59 => '"character_n" character(12) NULL DEFAULT NULL',
-            60 => '"character_varying" character varying NULL DEFAULT NULL',
-            61 => '"character_varying_n" character varying(12) NULL DEFAULT NULL',
+            27 => '"int_col" int NOT NULL',
+            28 => '"int_col_2" integer NOT NULL',
+            29 => '"numeric_col" numeric NOT NULL',
+            30 => '"numeric_col_2" numeric(10) NOT NULL',
+            31 => '"numeric_col_3" numeric(10,2) NOT NULL',
+            32 => '"double_p_2" double precision NOT NULL',
+            33 => '"double_p_3" double precision NOT NULL',
+            34 => '"real_col" real NOT NULL',
+            35 => '"float4_col" float4 NOT NULL',
+            36 => '"date_col" date NOT NULL',
+            37 => '"time_col" time NOT NULL',
+            38 => '"time_col_2" time with time zone NOT NULL',
+            39 => '"time_col_3" time without time zone NOT NULL',
+            40 => '"time_col_4" time(3) without time zone NOT NULL',
+            41 => '"timetz_col" timetz NOT NULL',
+            42 => '"timetz_col_2" timetz(3) NOT NULL',
+            43 => '"timestamp_col" timestamp NOT NULL',
+            44 => '"timestamp_col_2" timestamp with time zone NOT NULL',
+            45 => '"timestamp_col_3" timestamp without time zone NOT NULL',
+            46 => '"timestamp_col_4" timestamp(3) without time zone NOT NULL',
+            47 => '"timestamptz_col" timestamptz NOT NULL',
+            48 => '"timestamptz_col_2" timestamptz(3) NOT NULL',
+            49 => '"date2" date NOT NULL',
+            50 => '"timestamp_col_z" timestamp NOT NULL',
+            51 => '"bit_varying" bit varying NOT NULL',
+            52 => '"bit_varying_n" bit varying(8) NOT NULL',
+            53 => '"bit_varying_n_2" varbit NOT NULL',
+            54 => '"bit_varying_n_3" varbit(3) NOT NULL',
+            55 => '"bool_col" boolean NOT NULL',
+            56 => '"bool_col_2" bool NOT NULL',
+            57 => '"box_col" box NOT NULL',
+            58 => '"character_col" character NOT NULL',
+            59 => '"character_n" character(12) NOT NULL',
+            60 => '"character_varying" character varying NOT NULL',
+            61 => '"character_varying_n" character varying(12) NOT NULL',
             62 => '"json_col" json NOT NULL',
             63 => '"jsonb_col" jsonb NOT NULL',
             64 => '"json_col_def" json NOT NULL DEFAULT \'[]\'',
             65 => '"json_col_def_2" json NOT NULL DEFAULT \'[]\'',
-            66 => '"bytea_def" bytea NULL DEFAULT \'the bytea blob default\'',
-            67 => '"text_def" text NULL DEFAULT \'the text\'',
+            66 => '"bytea_def" bytea NOT NULL DEFAULT \'the bytea blob default\'',
+            67 => '"text_def" text NOT NULL DEFAULT \'the text\'',
             68 => '"json_def" json NOT NULL DEFAULT \'{"a":"b"}\'',
             69 => '"jsonb_def" jsonb NOT NULL DEFAULT \'{"ba":"bb"}\'',
-            70 => '"cidr_col" cidr NULL DEFAULT NULL',
-            71 => '"circle_col" circle NULL DEFAULT NULL',
-            72 => '"date_col_z" date NULL DEFAULT NULL',
-            73 => '"float8_col" float8 NULL DEFAULT NULL',
-            74 => '"inet_col" inet NULL DEFAULT NULL',
-            75 => '"interval_col" interval NULL DEFAULT NULL',
-            76 => '"interval_col_2" interval year NULL DEFAULT NULL',
-            77 => '"interval_col_3" interval day to second(3) NULL DEFAULT NULL',
-            78 => '"line_col" line NULL DEFAULT NULL',
-            79 => '"lseg_col" lseg NULL DEFAULT NULL',
-            80 => '"macaddr_col" macaddr NULL DEFAULT NULL',
-            81 => '"money_col" money NULL DEFAULT NULL',
-            82 => '"path_col" path NULL DEFAULT NULL',
-            83 => '"pg_lsn_col" pg_lsn NULL DEFAULT NULL',
-            84 => '"point_col" point NULL DEFAULT NULL',
-            85 => '"polygon_col" polygon NULL DEFAULT NULL',
+            70 => '"cidr_col" cidr NOT NULL',
+            71 => '"circle_col" circle NOT NULL',
+            72 => '"date_col_z" date NOT NULL',
+            73 => '"float8_col" float8 NOT NULL',
+            74 => '"inet_col" inet NOT NULL',
+            75 => '"interval_col" interval NOT NULL',
+            76 => '"interval_col_2" interval year NOT NULL',
+            77 => '"interval_col_3" interval day to second(3) NOT NULL',
+            78 => '"line_col" line NOT NULL',
+            79 => '"lseg_col" lseg NOT NULL',
+            80 => '"macaddr_col" macaddr NOT NULL',
+            81 => '"money_col" money NOT NULL',
+            82 => '"path_col" path NOT NULL',
+            83 => '"pg_lsn_col" pg_lsn NOT NULL',
+            84 => '"point_col" point NOT NULL',
+            85 => '"polygon_col" polygon NOT NULL',
             86 => '"serial_col" serial NOT NULL',
             87 => '"serial4_col" serial4 NOT NULL',
-            88 => '"tsquery_col" tsquery NULL DEFAULT NULL',
-            89 => '"tsvector_col" tsvector NULL',
-            90 => '"txid_snapshot_col" txid_snapshot NULL DEFAULT NULL',
-            91 => '"uuid_col" uuid NULL DEFAULT NULL',
-            92 => '"xml_col" xml NULL DEFAULT NULL',
+            88 => '"tsquery_col" tsquery NOT NULL',
+            89 => '"tsvector_col" tsvector NOT NULL',
+            90 => '"txid_snapshot_col" txid_snapshot NOT NULL',
+            91 => '"uuid_col" uuid NOT NULL',
+            92 => '"xml_col" xml NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
index fcf648ed..040061dd 100644
--- a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
@@ -10,17 +10,17 @@ public function safeUp()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => '"name" varchar(254) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->null()->defaultValue(null),
-            1 => '"first_name" varchar NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            1 => '"first_name" varchar NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
-            2 => '"dec_col" decimal(12,2) NULL DEFAULT 3.14',
+            2 => '"dec_col" decimal(12,2) NOT NULL DEFAULT 3.14',
             3 => '"str_col_def" varchar NOT NULL',
             4 => '"json_col" text NOT NULL DEFAULT \'fox jumps over dog\'',
             5 => '"json_col_2" jsonb NOT NULL DEFAULT \'[]\'',
             6 => '"numeric_col" double precision NOT NULL',
             7 => '"json_col_def_n" json NOT NULL DEFAULT \'[]\'',
             8 => '"json_col_def_n_2" json NOT NULL DEFAULT \'[]\'',
-            9 => '"text_col_array" text[] NULL DEFAULT NULL',
+            9 => '"text_col_array" text[] NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php
index 4bd08302..b48b6cfd 100644
--- a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php
+++ b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php
@@ -10,15 +10,15 @@ public function safeUp()
         $this->createTable('{{%newcolumns}}', [
             'id' => $this->primaryKey(),
             0 => '"name" varchar NOT NULL',
-            1 => '"first_name" varchar NULL DEFAULT NULL',
-            'last_name' => $this->text()->null()->defaultValue(null),
-            2 => '"dec_col" decimal(12,4) NULL DEFAULT NULL',
+            1 => '"first_name" varchar NOT NULL',
+            'last_name' => $this->text()->notNull(),
+            2 => '"dec_col" decimal(12,4) NOT NULL',
             3 => '"json_col" json NOT NULL',
-            4 => '"varchar_col" varchar NULL DEFAULT NULL',
-            5 => '"numeric_col" double precision NULL DEFAULT NULL',
+            4 => '"varchar_col" varchar NOT NULL',
+            5 => '"numeric_col" double precision NOT NULL',
             6 => '"json_col_def_n" json NOT NULL DEFAULT \'[]\'',
             7 => '"json_col_def_n_2" json NOT NULL DEFAULT \'[]\'',
-            8 => '"text_col_array" text[] NULL DEFAULT NULL',
+            8 => '"text_col_array" text[] NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
index 7fa8a01f..e47cd70d 100644
--- a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function safeUp()
         $this->createTable('{{%pristines}}', [
             0 => '"custom_id_col" serial primary key NOT NULL',
             1 => '"name" text NOT NULL',
-            'tag' => $this->text()->null()->defaultValue('4 leg'),
-            2 => '"new_col" varchar NULL DEFAULT NULL',
-            3 => '"col_5" decimal(12,4) NULL DEFAULT NULL',
-            4 => '"col_6" decimal(11,2) NULL DEFAULT NULL',
-            5 => '"col_7" decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull()->defaultValue('4 leg'),
+            2 => '"new_col" varchar NOT NULL',
+            3 => '"col_5" decimal(12,4) NOT NULL',
+            4 => '"col_6" decimal(11,2) NOT NULL',
+            5 => '"col_7" decimal(10,2) NOT NULL',
             6 => '"col_8" json NOT NULL',
-            7 => '"col_9" varchar NULL DEFAULT NULL',
-            8 => '"col_10" varchar NULL DEFAULT NULL',
-            9 => '"col_11" text NULL DEFAULT NULL',
-            10 => '"price" decimal(10,2) NULL DEFAULT 0',
+            7 => '"col_9" varchar NOT NULL',
+            8 => '"col_10" varchar NOT NULL',
+            9 => '"col_11" text NOT NULL',
+            10 => '"price" decimal(10,2) NOT NULL DEFAULT 0',
         ]);
         $this->addCommentOnColumn('{{%pristines}}', 'price', 'price in EUR');
     }
diff --git a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
index 9c002bea..44ad30b2 100644
--- a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,48 +9,48 @@ public function up()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => 'string_col varchar(255) NULL DEFAULT NULL',
-            1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
-            2 => 'text_col text NULL DEFAULT NULL',
-            3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
-            4 => 'char_4_col char(4) NULL DEFAULT NULL',
-            5 => 'char_5_col char NULL DEFAULT NULL',
+            0 => 'string_col varchar(255) NOT NULL',
+            1 => 'varchar_col varchar(132) NOT NULL',
+            2 => 'text_col text NOT NULL',
+            3 => 'varchar_4_col varchar(4) NOT NULL',
+            4 => 'char_4_col char(4) NOT NULL',
+            5 => 'char_5_col char NOT NULL',
             6 => 'char_6_col char NOT NULL',
             7 => 'char_7_col char(6) NOT NULL',
-            8 => 'char_8_col char NULL DEFAULT \'d\'',
-            9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
-            10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
-            11 => 'blob_col blob NULL DEFAULT NULL',
-            12 => 'bit_col bit NULL DEFAULT NULL',
-            13 => 'bit_2 bit(1) NULL DEFAULT NULL',
-            14 => 'bit_3 bit(64) NULL DEFAULT NULL',
-            15 => 'ti tinyint NULL DEFAULT NULL',
-            16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
-            17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
-            18 => 'si_col smallint NULL DEFAULT NULL',
-            19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
-            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
-            21 => 'bi bigint NULL DEFAULT NULL',
-            22 => 'int_col int NULL DEFAULT NULL',
-            23 => 'int_col_2 integer NULL DEFAULT NULL',
-            24 => 'numeric_col numeric NULL DEFAULT NULL',
-            25 => 'float_col float NULL DEFAULT NULL',
-            26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
-            27 => 'float_3 float(8) NULL DEFAULT NULL',
-            28 => 'double_col double NULL DEFAULT NULL',
-            29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
-            30 => 'double_p_2 double precision NULL DEFAULT NULL',
-            31 => 'real_col real NULL DEFAULT NULL',
-            32 => 'date_col date NULL DEFAULT NULL',
-            33 => 'time_col time NULL DEFAULT NULL',
-            34 => 'datetime_col datetime NULL DEFAULT NULL',
-            35 => 'timestamp_col timestamp NULL DEFAULT NULL',
-            36 => 'year_col year NULL DEFAULT NULL',
+            8 => 'char_8_col char NOT NULL DEFAULT \'d\'',
+            9 => 'decimal_col decimal(12,3) NOT NULL',
+            10 => 'varbinary_col varbinary(5) NOT NULL',
+            11 => 'blob_col blob NOT NULL',
+            12 => 'bit_col bit NOT NULL',
+            13 => 'bit_2 bit(1) NOT NULL',
+            14 => 'bit_3 bit(64) NOT NULL',
+            15 => 'ti tinyint NOT NULL',
+            16 => 'ti_2 tinyint(1) NOT NULL',
+            17 => 'ti_3 tinyint(2) NOT NULL',
+            18 => 'si_col smallint NOT NULL',
+            19 => 'si_col_2 smallint unsigned zerofill NOT NULL',
+            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NOT NULL DEFAULT 7',
+            21 => 'bi bigint NOT NULL',
+            22 => 'int_col int NOT NULL',
+            23 => 'int_col_2 integer NOT NULL',
+            24 => 'numeric_col numeric NOT NULL',
+            25 => 'float_col float NOT NULL',
+            26 => 'float_2 float(10, 2) NOT NULL',
+            27 => 'float_3 float(8) NOT NULL',
+            28 => 'double_col double NOT NULL',
+            29 => 'double_p double precision(10,2) NOT NULL',
+            30 => 'double_p_2 double precision NOT NULL',
+            31 => 'real_col real NOT NULL',
+            32 => 'date_col date NOT NULL',
+            33 => 'time_col time NOT NULL',
+            34 => 'datetime_col datetime NOT NULL',
+            35 => 'timestamp_col timestamp NOT NULL',
+            36 => 'year_col year NOT NULL',
             37 => 'json_col json NOT NULL',
             38 => 'json_col_def json NOT NULL DEFAULT \'[]\'',
             39 => 'json_col_def_2 json NOT NULL DEFAULT \'[]\'',
-            40 => 'blob_def blob NULL DEFAULT \'the blob\'',
-            41 => 'text_def text NULL DEFAULT \'the text\'',
+            40 => 'blob_def blob NOT NULL DEFAULT \'the blob\'',
+            41 => 'text_def text NOT NULL DEFAULT \'the text\'',
             42 => 'json_def json NOT NULL DEFAULT \'{"a":"b"}\'',
         ]);
     }
diff --git a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
index 1de3d8d5..4c649990 100644
--- a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
@@ -10,14 +10,14 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->null()->defaultValue(null),
-            1 => 'first_name varchar(255) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
-            2 => 'dec_col decimal(12,2) NULL DEFAULT 3.14',
+            2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
             3 => 'str_col_def varchar(3) NOT NULL',
             4 => 'json_col text NOT NULL DEFAULT \'fox jumps over dog\'',
             5 => 'json_col_2 json NOT NULL DEFAULT \'[]\'',
-            6 => 'numeric_col double precision NULL DEFAULT NULL',
+            6 => 'numeric_col double precision NOT NULL',
             7 => 'json_col_def_n json NOT NULL DEFAULT \'[]\'',
             8 => 'json_col_def_n_2 json NOT NULL DEFAULT \'[]\'',
         ]);
diff --git a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000002_change_table_newcolumns.php b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000002_change_table_newcolumns.php
index fb66659b..19ef0245 100644
--- a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000002_change_table_newcolumns.php
+++ b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000002_change_table_newcolumns.php
@@ -7,11 +7,11 @@ class m200000_000002_change_table_newcolumns extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->null()->defaultValue(null)->after('name'));
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN dec_col decimal(12,4) NULL DEFAULT NULL AFTER last_name')->execute();
+        $this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->notNull()->after('name'));
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN dec_col decimal(12,4) NOT NULL AFTER last_name')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN json_col json NOT NULL AFTER dec_col')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN varchar_col varchar(5) NULL DEFAULT NULL AFTER json_col')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN numeric_col double precision NULL DEFAULT NULL AFTER varchar_col')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN varchar_col varchar(5) NOT NULL AFTER json_col')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN numeric_col double precision NOT NULL AFTER varchar_col')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN json_col_def_n json NOT NULL DEFAULT \'[]\'')->execute();
     }
 
diff --git a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
index 7c0b936f..746b4549 100644
--- a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function up()
         $this->createTable('{{%pristines}}', [
             0 => 'custom_id_col integer primary key auto_increment NOT NULL',
             1 => 'name text NOT NULL',
-            'tag' => $this->text()->null()->defaultValue('4 leg'),
-            2 => 'new_col varchar(17) NULL DEFAULT NULL',
-            3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
-            4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
-            5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull()->defaultValue('4 leg'),
+            2 => 'new_col varchar(17) NOT NULL',
+            3 => 'col_5 decimal(12,4) NOT NULL',
+            4 => 'col_6 decimal(11,2) NOT NULL',
+            5 => 'col_7 decimal(10,2) NOT NULL',
             6 => 'col_8 json NOT NULL',
-            7 => 'col_9 varchar(9) NULL DEFAULT NULL',
-            8 => 'col_10 varchar(10) NULL DEFAULT NULL',
-            9 => 'col_11 text NULL DEFAULT NULL',
-            10 => 'price decimal(10,2) NULL DEFAULT 0 COMMENT \'price in EUR\'',
+            7 => 'col_9 varchar(9) NOT NULL',
+            8 => 'col_10 varchar(10) NOT NULL',
+            9 => 'col_11 text NOT NULL',
+            10 => 'price decimal(10,2) NOT NULL DEFAULT 0 COMMENT \'price in EUR\'',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
index 2cda660f..6dfa9ea3 100644
--- a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,48 +9,48 @@ public function up()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => 'string_col varchar(255) NULL DEFAULT NULL',
-            1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
-            2 => 'text_col text NULL',
-            3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
-            4 => 'char_4_col char(4) NULL DEFAULT NULL',
-            5 => 'char_5_col char NULL DEFAULT NULL',
+            0 => 'string_col varchar(255) NOT NULL',
+            1 => 'varchar_col varchar(132) NOT NULL',
+            2 => 'text_col text NOT NULL',
+            3 => 'varchar_4_col varchar(4) NOT NULL',
+            4 => 'char_4_col char(4) NOT NULL',
+            5 => 'char_5_col char NOT NULL',
             6 => 'char_6_col char NOT NULL',
             7 => 'char_7_col char(6) NOT NULL',
-            8 => 'char_8_col char NULL DEFAULT \'d\'',
-            9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
-            10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
-            11 => 'blob_col blob NULL',
-            12 => 'bit_col bit NULL DEFAULT NULL',
-            13 => 'bit_2 bit(1) NULL DEFAULT NULL',
-            14 => 'bit_3 bit(64) NULL DEFAULT NULL',
-            15 => 'ti tinyint NULL DEFAULT NULL',
-            16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
-            17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
-            18 => 'si_col smallint NULL DEFAULT NULL',
-            19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
-            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
-            21 => 'bi bigint NULL DEFAULT NULL',
-            22 => 'int_col int NULL DEFAULT NULL',
-            23 => 'int_col_2 integer NULL DEFAULT NULL',
-            24 => 'numeric_col numeric NULL DEFAULT NULL',
-            25 => 'float_col float NULL DEFAULT NULL',
-            26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
-            27 => 'float_3 float(8) NULL DEFAULT NULL',
-            28 => 'double_col double NULL DEFAULT NULL',
-            29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
-            30 => 'double_p_2 double precision NULL DEFAULT NULL',
-            31 => 'real_col real NULL DEFAULT NULL',
-            32 => 'date_col date NULL DEFAULT NULL',
-            33 => 'time_col time NULL DEFAULT NULL',
-            34 => 'datetime_col datetime NULL DEFAULT NULL',
-            35 => 'timestamp_col timestamp NULL DEFAULT NULL',
-            36 => 'year_col year NULL DEFAULT NULL',
+            8 => 'char_8_col char NOT NULL DEFAULT \'d\'',
+            9 => 'decimal_col decimal(12,3) NOT NULL',
+            10 => 'varbinary_col varbinary(5) NOT NULL',
+            11 => 'blob_col blob NOT NULL',
+            12 => 'bit_col bit NOT NULL',
+            13 => 'bit_2 bit(1) NOT NULL',
+            14 => 'bit_3 bit(64) NOT NULL',
+            15 => 'ti tinyint NOT NULL',
+            16 => 'ti_2 tinyint(1) NOT NULL',
+            17 => 'ti_3 tinyint(2) NOT NULL',
+            18 => 'si_col smallint NOT NULL',
+            19 => 'si_col_2 smallint unsigned zerofill NOT NULL',
+            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NOT NULL DEFAULT 7',
+            21 => 'bi bigint NOT NULL',
+            22 => 'int_col int NOT NULL',
+            23 => 'int_col_2 integer NOT NULL',
+            24 => 'numeric_col numeric NOT NULL',
+            25 => 'float_col float NOT NULL',
+            26 => 'float_2 float(10, 2) NOT NULL',
+            27 => 'float_3 float(8) NOT NULL',
+            28 => 'double_col double NOT NULL',
+            29 => 'double_p double precision(10,2) NOT NULL',
+            30 => 'double_p_2 double precision NOT NULL',
+            31 => 'real_col real NOT NULL',
+            32 => 'date_col date NOT NULL',
+            33 => 'time_col time NOT NULL',
+            34 => 'datetime_col datetime NOT NULL',
+            35 => 'timestamp_col timestamp NOT NULL',
+            36 => 'year_col year NOT NULL',
             37 => 'json_col json NOT NULL',
             38 => 'json_col_def json NOT NULL',
             39 => 'json_col_def_2 json NOT NULL',
-            40 => 'blob_def blob NULL',
-            41 => 'text_def text NULL',
+            40 => 'blob_def blob NOT NULL',
+            41 => 'text_def text NOT NULL',
             42 => 'json_def json NOT NULL',
         ]);
     }
diff --git a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
index 8c84e731..15954d2a 100644
--- a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
@@ -10,14 +10,14 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->null(),
-            1 => 'first_name varchar(255) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null(),
-            2 => 'dec_col decimal(12,2) NULL DEFAULT 3.14',
+            2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
             3 => 'str_col_def varchar(3) NOT NULL',
             4 => 'json_col text NOT NULL',
             5 => 'json_col_2 json NOT NULL',
-            6 => 'numeric_col double precision NULL DEFAULT NULL',
+            6 => 'numeric_col double precision NOT NULL',
             7 => 'json_col_def_n json NOT NULL',
             8 => 'json_col_def_n_2 json NOT NULL',
         ]);
diff --git a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000002_change_table_newcolumns.php b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000002_change_table_newcolumns.php
index 0139e53d..8c21acfb 100644
--- a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000002_change_table_newcolumns.php
+++ b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000002_change_table_newcolumns.php
@@ -7,11 +7,11 @@ class m200000_000002_change_table_newcolumns extends \yii\db\Migration
 {
     public function up()
     {
-        $this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->null()->after('name'));
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN dec_col decimal(12,4) NULL DEFAULT NULL AFTER last_name')->execute();
+        $this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->notNull()->after('name'));
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN dec_col decimal(12,4) NOT NULL AFTER last_name')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN json_col json NOT NULL AFTER dec_col')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN varchar_col varchar(5) NULL DEFAULT NULL AFTER json_col')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN numeric_col double precision NULL DEFAULT NULL AFTER varchar_col')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN varchar_col varchar(5) NOT NULL AFTER json_col')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN numeric_col double precision NOT NULL AFTER varchar_col')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN json_col_def_n json NOT NULL')->execute();
     }
 
diff --git a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
index 50881e9d..96f3acdc 100644
--- a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function up()
         $this->createTable('{{%pristines}}', [
             0 => 'custom_id_col integer primary key auto_increment NOT NULL',
             1 => 'name text NOT NULL',
-            'tag' => $this->text()->null(),
-            2 => 'new_col varchar(17) NULL DEFAULT NULL',
-            3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
-            4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
-            5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            2 => 'new_col varchar(17) NOT NULL',
+            3 => 'col_5 decimal(12,4) NOT NULL',
+            4 => 'col_6 decimal(11,2) NOT NULL',
+            5 => 'col_7 decimal(10,2) NOT NULL',
             6 => 'col_8 json NOT NULL',
-            7 => 'col_9 varchar(9) NULL DEFAULT NULL',
-            8 => 'col_10 varchar(10) NULL DEFAULT NULL',
-            9 => 'col_11 text NULL',
-            10 => 'price decimal(10,2) NULL DEFAULT 0 COMMENT \'price in EUR\'',
+            7 => 'col_9 varchar(9) NOT NULL',
+            8 => 'col_10 varchar(10) NOT NULL',
+            9 => 'col_11 text NOT NULL',
+            10 => 'price decimal(10,2) NOT NULL DEFAULT 0 COMMENT \'price in EUR\'',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
index e0cac52a..b3239c59 100644
--- a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,99 +9,99 @@ public function safeUp()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => '"string_col" varchar NULL DEFAULT NULL',
-            1 => '"varchar_col" varchar NULL DEFAULT NULL',
-            2 => '"text_col" text NULL DEFAULT NULL',
-            3 => '"text_col_array" text[] NULL DEFAULT NULL',
-            4 => '"varchar_4_col" varchar(4) NULL DEFAULT NULL',
-            5 => '"varchar_5_col" varchar(5) NULL DEFAULT NULL',
-            6 => '"char_4_col" char(4) NULL DEFAULT NULL',
-            7 => '"char_5_col" char NULL DEFAULT NULL',
+            0 => '"string_col" varchar NOT NULL',
+            1 => '"varchar_col" varchar NOT NULL',
+            2 => '"text_col" text NOT NULL',
+            3 => '"text_col_array" text[] NOT NULL',
+            4 => '"varchar_4_col" varchar(4) NOT NULL',
+            5 => '"varchar_5_col" varchar(5) NOT NULL',
+            6 => '"char_4_col" char(4) NOT NULL',
+            7 => '"char_5_col" char NOT NULL',
             8 => '"char_6_col" char NOT NULL',
             9 => '"char_7_col" char(6) NOT NULL',
-            10 => '"char_8_col" char NULL DEFAULT \'d\'',
-            11 => '"decimal_col" decimal(12,3) NULL DEFAULT NULL',
-            12 => '"bytea_col_2" bytea NULL DEFAULT NULL',
-            13 => '"bit_col" bit NULL DEFAULT NULL',
-            14 => '"bit_2" bit(1) NULL DEFAULT NULL',
-            15 => '"bit_3" bit(64) NULL DEFAULT NULL',
-            16 => '"ti" smallint NULL DEFAULT NULL',
-            17 => '"int2_col" int2 NULL DEFAULT NULL',
+            10 => '"char_8_col" char NOT NULL DEFAULT \'d\'',
+            11 => '"decimal_col" decimal(12,3) NOT NULL',
+            12 => '"bytea_col_2" bytea NOT NULL',
+            13 => '"bit_col" bit NOT NULL',
+            14 => '"bit_2" bit(1) NOT NULL',
+            15 => '"bit_3" bit(64) NOT NULL',
+            16 => '"ti" smallint NOT NULL',
+            17 => '"int2_col" int2 NOT NULL',
             18 => '"smallserial_col" smallserial NOT NULL',
             19 => '"serial2_col" serial2 NOT NULL',
-            20 => '"si_col" smallint NULL DEFAULT NULL',
-            21 => '"si_col_2" smallint NULL DEFAULT NULL',
-            22 => '"bi" bigint NULL DEFAULT NULL',
-            23 => '"bi2" int8 NULL DEFAULT NULL',
-            24 => '"int4_col" int4 NULL DEFAULT NULL',
+            20 => '"si_col" smallint NOT NULL',
+            21 => '"si_col_2" smallint NOT NULL',
+            22 => '"bi" bigint NOT NULL',
+            23 => '"bi2" int8 NOT NULL',
+            24 => '"int4_col" int4 NOT NULL',
             25 => '"bigserial_col" bigserial NOT NULL',
             26 => '"bigserial_col_2" serial8 NOT NULL',
-            27 => '"int_col" int NULL DEFAULT NULL',
-            28 => '"int_col_2" integer NULL DEFAULT NULL',
-            29 => '"numeric_col" numeric NULL DEFAULT NULL',
-            30 => '"numeric_col_2" numeric(10) NULL DEFAULT NULL',
-            31 => '"numeric_col_3" numeric(10,2) NULL DEFAULT NULL',
-            32 => '"double_p_2" double precision NULL DEFAULT NULL',
-            33 => '"double_p_3" double precision NULL DEFAULT NULL',
-            34 => '"real_col" real NULL DEFAULT NULL',
-            35 => '"float4_col" float4 NULL DEFAULT NULL',
-            36 => '"date_col" date NULL DEFAULT NULL',
-            37 => '"time_col" time NULL DEFAULT NULL',
-            38 => '"time_col_2" time with time zone NULL DEFAULT NULL',
-            39 => '"time_col_3" time without time zone NULL DEFAULT NULL',
-            40 => '"time_col_4" time(3) without time zone NULL DEFAULT NULL',
-            41 => '"timetz_col" timetz NULL DEFAULT NULL',
-            42 => '"timetz_col_2" timetz(3) NULL DEFAULT NULL',
-            43 => '"timestamp_col" timestamp NULL DEFAULT NULL',
-            44 => '"timestamp_col_2" timestamp with time zone NULL DEFAULT NULL',
-            45 => '"timestamp_col_3" timestamp without time zone NULL DEFAULT NULL',
-            46 => '"timestamp_col_4" timestamp(3) without time zone NULL DEFAULT NULL',
-            47 => '"timestamptz_col" timestamptz NULL DEFAULT NULL',
-            48 => '"timestamptz_col_2" timestamptz(3) NULL DEFAULT NULL',
-            49 => '"date2" date NULL DEFAULT NULL',
-            50 => '"timestamp_col_z" timestamp NULL DEFAULT NULL',
-            51 => '"bit_varying" bit varying NULL DEFAULT NULL',
-            52 => '"bit_varying_n" bit varying(8) NULL DEFAULT NULL',
-            53 => '"bit_varying_n_2" varbit NULL DEFAULT NULL',
-            54 => '"bit_varying_n_3" varbit(3) NULL DEFAULT NULL',
-            55 => '"bool_col" boolean NULL DEFAULT NULL',
-            56 => '"bool_col_2" bool NULL DEFAULT NULL',
-            57 => '"box_col" box NULL DEFAULT NULL',
-            58 => '"character_col" character NULL DEFAULT NULL',
-            59 => '"character_n" character(12) NULL DEFAULT NULL',
-            60 => '"character_varying" character varying NULL DEFAULT NULL',
-            61 => '"character_varying_n" character varying(12) NULL DEFAULT NULL',
+            27 => '"int_col" int NOT NULL',
+            28 => '"int_col_2" integer NOT NULL',
+            29 => '"numeric_col" numeric NOT NULL',
+            30 => '"numeric_col_2" numeric(10) NOT NULL',
+            31 => '"numeric_col_3" numeric(10,2) NOT NULL',
+            32 => '"double_p_2" double precision NOT NULL',
+            33 => '"double_p_3" double precision NOT NULL',
+            34 => '"real_col" real NOT NULL',
+            35 => '"float4_col" float4 NOT NULL',
+            36 => '"date_col" date NOT NULL',
+            37 => '"time_col" time NOT NULL',
+            38 => '"time_col_2" time with time zone NOT NULL',
+            39 => '"time_col_3" time without time zone NOT NULL',
+            40 => '"time_col_4" time(3) without time zone NOT NULL',
+            41 => '"timetz_col" timetz NOT NULL',
+            42 => '"timetz_col_2" timetz(3) NOT NULL',
+            43 => '"timestamp_col" timestamp NOT NULL',
+            44 => '"timestamp_col_2" timestamp with time zone NOT NULL',
+            45 => '"timestamp_col_3" timestamp without time zone NOT NULL',
+            46 => '"timestamp_col_4" timestamp(3) without time zone NOT NULL',
+            47 => '"timestamptz_col" timestamptz NOT NULL',
+            48 => '"timestamptz_col_2" timestamptz(3) NOT NULL',
+            49 => '"date2" date NOT NULL',
+            50 => '"timestamp_col_z" timestamp NOT NULL',
+            51 => '"bit_varying" bit varying NOT NULL',
+            52 => '"bit_varying_n" bit varying(8) NOT NULL',
+            53 => '"bit_varying_n_2" varbit NOT NULL',
+            54 => '"bit_varying_n_3" varbit(3) NOT NULL',
+            55 => '"bool_col" boolean NOT NULL',
+            56 => '"bool_col_2" bool NOT NULL',
+            57 => '"box_col" box NOT NULL',
+            58 => '"character_col" character NOT NULL',
+            59 => '"character_n" character(12) NOT NULL',
+            60 => '"character_varying" character varying NOT NULL',
+            61 => '"character_varying_n" character varying(12) NOT NULL',
             62 => '"json_col" json NOT NULL',
             63 => '"jsonb_col" jsonb NOT NULL',
             64 => '"json_col_def" json NOT NULL DEFAULT \'[]\'',
             65 => '"json_col_def_2" json NOT NULL DEFAULT \'[]\'',
-            66 => '"bytea_def" bytea NULL DEFAULT \'the bytea blob default\'',
-            67 => '"text_def" text NULL DEFAULT \'the text\'',
+            66 => '"bytea_def" bytea NOT NULL DEFAULT \'the bytea blob default\'',
+            67 => '"text_def" text NOT NULL DEFAULT \'the text\'',
             68 => '"json_def" json NOT NULL DEFAULT \'{"a":"b"}\'',
             69 => '"jsonb_def" jsonb NOT NULL DEFAULT \'{"ba":"bb"}\'',
-            70 => '"cidr_col" cidr NULL DEFAULT NULL',
-            71 => '"circle_col" circle NULL DEFAULT NULL',
-            72 => '"date_col_z" date NULL DEFAULT NULL',
-            73 => '"float8_col" float8 NULL DEFAULT NULL',
-            74 => '"inet_col" inet NULL DEFAULT NULL',
-            75 => '"interval_col" interval NULL DEFAULT NULL',
-            76 => '"interval_col_2" interval year NULL DEFAULT NULL',
-            77 => '"interval_col_3" interval day to second(3) NULL DEFAULT NULL',
-            78 => '"line_col" line NULL DEFAULT NULL',
-            79 => '"lseg_col" lseg NULL DEFAULT NULL',
-            80 => '"macaddr_col" macaddr NULL DEFAULT NULL',
-            81 => '"money_col" money NULL DEFAULT NULL',
-            82 => '"path_col" path NULL DEFAULT NULL',
-            83 => '"pg_lsn_col" pg_lsn NULL DEFAULT NULL',
-            84 => '"point_col" point NULL DEFAULT NULL',
-            85 => '"polygon_col" polygon NULL DEFAULT NULL',
+            70 => '"cidr_col" cidr NOT NULL',
+            71 => '"circle_col" circle NOT NULL',
+            72 => '"date_col_z" date NOT NULL',
+            73 => '"float8_col" float8 NOT NULL',
+            74 => '"inet_col" inet NOT NULL',
+            75 => '"interval_col" interval NOT NULL',
+            76 => '"interval_col_2" interval year NOT NULL',
+            77 => '"interval_col_3" interval day to second(3) NOT NULL',
+            78 => '"line_col" line NOT NULL',
+            79 => '"lseg_col" lseg NOT NULL',
+            80 => '"macaddr_col" macaddr NOT NULL',
+            81 => '"money_col" money NOT NULL',
+            82 => '"path_col" path NOT NULL',
+            83 => '"pg_lsn_col" pg_lsn NOT NULL',
+            84 => '"point_col" point NOT NULL',
+            85 => '"polygon_col" polygon NOT NULL',
             86 => '"serial_col" serial NOT NULL',
             87 => '"serial4_col" serial4 NOT NULL',
-            88 => '"tsquery_col" tsquery NULL DEFAULT NULL',
-            89 => '"tsvector_col" tsvector NULL',
-            90 => '"txid_snapshot_col" txid_snapshot NULL DEFAULT NULL',
-            91 => '"uuid_col" uuid NULL DEFAULT NULL',
-            92 => '"xml_col" xml NULL DEFAULT NULL',
+            88 => '"tsquery_col" tsquery NOT NULL',
+            89 => '"tsvector_col" tsvector NOT NULL',
+            90 => '"txid_snapshot_col" txid_snapshot NOT NULL',
+            91 => '"uuid_col" uuid NOT NULL',
+            92 => '"xml_col" xml NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
index fcf648ed..040061dd 100644
--- a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
@@ -10,17 +10,17 @@ public function safeUp()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => '"name" varchar(254) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->null()->defaultValue(null),
-            1 => '"first_name" varchar NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            1 => '"first_name" varchar NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
-            2 => '"dec_col" decimal(12,2) NULL DEFAULT 3.14',
+            2 => '"dec_col" decimal(12,2) NOT NULL DEFAULT 3.14',
             3 => '"str_col_def" varchar NOT NULL',
             4 => '"json_col" text NOT NULL DEFAULT \'fox jumps over dog\'',
             5 => '"json_col_2" jsonb NOT NULL DEFAULT \'[]\'',
             6 => '"numeric_col" double precision NOT NULL',
             7 => '"json_col_def_n" json NOT NULL DEFAULT \'[]\'',
             8 => '"json_col_def_n_2" json NOT NULL DEFAULT \'[]\'',
-            9 => '"text_col_array" text[] NULL DEFAULT NULL',
+            9 => '"text_col_array" text[] NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000002_change_table_newcolumns.php b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000002_change_table_newcolumns.php
index b152635f..06ef713c 100644
--- a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000002_change_table_newcolumns.php
+++ b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000002_change_table_newcolumns.php
@@ -7,15 +7,15 @@ class m200000_000002_change_table_newcolumns extends \yii\db\Migration
 {
     public function safeUp()
     {
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "first_name" varchar NULL DEFAULT NULL')->execute();
-        $this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->null()->defaultValue(null));
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "dec_col" decimal(12,4) NULL DEFAULT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "first_name" varchar NOT NULL')->execute();
+        $this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->notNull());
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "dec_col" decimal(12,4) NOT NULL')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "json_col" json NOT NULL')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "varchar_col" varchar NULL DEFAULT NULL')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "numeric_col" double precision NULL DEFAULT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "varchar_col" varchar NOT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "numeric_col" double precision NOT NULL')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "json_col_def_n" json NOT NULL DEFAULT \'[]\'')->execute();
         $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "json_col_def_n_2" json NOT NULL DEFAULT \'[]\'')->execute();
-        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "text_col_array" text[] NULL DEFAULT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%newcolumns}} ADD COLUMN "text_col_array" text[] NOT NULL')->execute();
     }
 
     public function safeDown()
diff --git a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
index 7fa8a01f..e47cd70d 100644
--- a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function safeUp()
         $this->createTable('{{%pristines}}', [
             0 => '"custom_id_col" serial primary key NOT NULL',
             1 => '"name" text NOT NULL',
-            'tag' => $this->text()->null()->defaultValue('4 leg'),
-            2 => '"new_col" varchar NULL DEFAULT NULL',
-            3 => '"col_5" decimal(12,4) NULL DEFAULT NULL',
-            4 => '"col_6" decimal(11,2) NULL DEFAULT NULL',
-            5 => '"col_7" decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull()->defaultValue('4 leg'),
+            2 => '"new_col" varchar NOT NULL',
+            3 => '"col_5" decimal(12,4) NOT NULL',
+            4 => '"col_6" decimal(11,2) NOT NULL',
+            5 => '"col_7" decimal(10,2) NOT NULL',
             6 => '"col_8" json NOT NULL',
-            7 => '"col_9" varchar NULL DEFAULT NULL',
-            8 => '"col_10" varchar NULL DEFAULT NULL',
-            9 => '"col_11" text NULL DEFAULT NULL',
-            10 => '"price" decimal(10,2) NULL DEFAULT 0',
+            7 => '"col_9" varchar NOT NULL',
+            8 => '"col_10" varchar NOT NULL',
+            9 => '"col_11" text NOT NULL',
+            10 => '"price" decimal(10,2) NOT NULL DEFAULT 0',
         ]);
         $this->addCommentOnColumn('{{%pristines}}', 'price', 'price in EUR');
     }

From 039af2b8aeea384292d7de340487a8d2702873d3 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Tue, 11 Mar 2025 07:20:36 +0530
Subject: [PATCH 07/12] Change lot of tests 4 - Fix failing tests + Add docs

---
 README.md                                     |  11 +-
 ...200000_000005_change_table_v2_comments.php |   4 +-
 ...000_000000_create_table_alldbdatatypes.php |  74 ++++----
 ...200000_000001_change_table_editcolumns.php |   6 +-
 ...m200000_000002_create_table_newcolumns.php |   8 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php |  74 ++++----
 ...200000_000001_change_table_editcolumns.php |   6 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 ...000_000000_create_table_alldbdatatypes.php | 158 +++++++++---------
 ...200000_000001_change_table_editcolumns.php |   4 +-
 ...m200000_000002_create_table_newcolumns.php |  12 +-
 .../m200000_000003_create_table_pristines.php |  18 +-
 .../fresh/mysql/x_db_type_mysql.yaml          |   1 +
 .../fresh/pgsql/x_db_type_pgsql.yaml          |   2 +
 .../models/mariamodel/base/Alldbdatatype.php  |   2 +-
 .../app/models/mariamodel/base/Editcolumn.php |   2 +-
 .../mysql/app/models/base/Alldbdatatype.php   |   2 +-
 .../mysql/app/models/base/Editcolumn.php      |   2 +-
 .../models/pgsqlmodel/base/Alldbdatatype.php  |   2 +-
 .../app/models/pgsqlmodel/base/Editcolumn.php |   2 +-
 tests/unit/XDbTypeTest.php                    |   2 +-
 22 files changed, 217 insertions(+), 211 deletions(-)

diff --git a/README.md b/README.md
index f7eadf30..02cd2991 100644
--- a/README.md
+++ b/README.md
@@ -597,10 +597,13 @@ User:
 
 ## Handling of `NOT NULL` constraints
 
-`NOT NULL` in DB migrations is determined by `nullable` and `required` properties of the OpenAPI schema.
+`NOT NULL` in DB migrations is determined by `nullable` properties of the OpenAPI schema.
 e.g. attribute = 'my_property'.
 
 - 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)):
+- `nullable` and `required` of OpenAPI spec is not related. They have separate purpose.
+- `nullable` will help in creating migrations ([`null()`](https://www.yiiframework.com/doc/api/2.0/yii-db-columnschemabuilder#null()-detail) and [`notNull()`](https://www.yiiframework.com/doc/api/2.0/yii-db-columnschemabuilder#notNull()-detail)) only
+- `required` will help in creating model validation rules only
 
 ```yaml
   ExampleSchema:
@@ -609,7 +612,7 @@ e.g. attribute = 'my_property'.
         type: string
 ```
 
-- If you define attribute in "required", then it is `NOT NULL`
+- In below example, if you define attribute in "required", then it is `NOT NULL`, because `nullable` is present and it defaults to `false`
 
 ```yaml
   ExampleSchema:
@@ -620,7 +623,7 @@ e.g. attribute = 'my_property'.
         type: string
 ```
 
-- If you define attribute via "nullable", then it overrides "required", e.g. allow `NULL` in this case:
+- If you define attribute via "nullable", e.g. allow `NULL` in this case:
 
 ```yaml
   ExampleSchema:
@@ -632,7 +635,7 @@ e.g. attribute = 'my_property'.
         nullable: true
 ```
 
-- If you define attribute via "nullable", then it overrides "required", e.g. `NOT NULL` in this case:
+- If you define attribute via "nullable" e.g. `NOT NULL` in this case:
 
 ```yaml
   test_table:
diff --git a/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php b/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
index b74e6258..642be14f 100644
--- a/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
+++ b/tests/specs/blog_v2/migrations_mysql_db/m200000_000005_change_table_v2_comments.php
@@ -7,8 +7,8 @@ class m200000_000005_change_table_v2_comments extends \yii\db\Migration
 {
     public function up()
     {
-        $this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
         $this->dropForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}');
+        $this->dropForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}');
         $this->addColumn('{{%v2_comments}}', 'user_id', $this->bigInteger()->notNull()->after('post_id')->comment('The User'));
         $this->dropColumn('{{%v2_comments}}', 'author_id');
         $this->alterColumn('{{%v2_comments}}', 'message', $this->text()->notNull());
@@ -27,7 +27,7 @@ public function down()
         $this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL');
         $this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull()->after('post_id'));
         $this->dropColumn('{{%v2_comments}}', 'user_id');
-        $this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'post_id', 'itt_v2_posts', 'uid');
         $this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'author_id', 'itt_v2_users', 'id');
+        $this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'post_id', 'itt_v2_posts', 'uid');
     }
 }
diff --git a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
index 9c002bea..44ad30b2 100644
--- a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,48 +9,48 @@ public function up()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => 'string_col varchar(255) NULL DEFAULT NULL',
-            1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
-            2 => 'text_col text NULL DEFAULT NULL',
-            3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
-            4 => 'char_4_col char(4) NULL DEFAULT NULL',
-            5 => 'char_5_col char NULL DEFAULT NULL',
+            0 => 'string_col varchar(255) NOT NULL',
+            1 => 'varchar_col varchar(132) NOT NULL',
+            2 => 'text_col text NOT NULL',
+            3 => 'varchar_4_col varchar(4) NOT NULL',
+            4 => 'char_4_col char(4) NOT NULL',
+            5 => 'char_5_col char NOT NULL',
             6 => 'char_6_col char NOT NULL',
             7 => 'char_7_col char(6) NOT NULL',
-            8 => 'char_8_col char NULL DEFAULT \'d\'',
-            9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
-            10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
-            11 => 'blob_col blob NULL DEFAULT NULL',
-            12 => 'bit_col bit NULL DEFAULT NULL',
-            13 => 'bit_2 bit(1) NULL DEFAULT NULL',
-            14 => 'bit_3 bit(64) NULL DEFAULT NULL',
-            15 => 'ti tinyint NULL DEFAULT NULL',
-            16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
-            17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
-            18 => 'si_col smallint NULL DEFAULT NULL',
-            19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
-            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
-            21 => 'bi bigint NULL DEFAULT NULL',
-            22 => 'int_col int NULL DEFAULT NULL',
-            23 => 'int_col_2 integer NULL DEFAULT NULL',
-            24 => 'numeric_col numeric NULL DEFAULT NULL',
-            25 => 'float_col float NULL DEFAULT NULL',
-            26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
-            27 => 'float_3 float(8) NULL DEFAULT NULL',
-            28 => 'double_col double NULL DEFAULT NULL',
-            29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
-            30 => 'double_p_2 double precision NULL DEFAULT NULL',
-            31 => 'real_col real NULL DEFAULT NULL',
-            32 => 'date_col date NULL DEFAULT NULL',
-            33 => 'time_col time NULL DEFAULT NULL',
-            34 => 'datetime_col datetime NULL DEFAULT NULL',
-            35 => 'timestamp_col timestamp NULL DEFAULT NULL',
-            36 => 'year_col year NULL DEFAULT NULL',
+            8 => 'char_8_col char NOT NULL DEFAULT \'d\'',
+            9 => 'decimal_col decimal(12,3) NOT NULL',
+            10 => 'varbinary_col varbinary(5) NOT NULL',
+            11 => 'blob_col blob NOT NULL',
+            12 => 'bit_col bit NOT NULL',
+            13 => 'bit_2 bit(1) NOT NULL',
+            14 => 'bit_3 bit(64) NOT NULL',
+            15 => 'ti tinyint NOT NULL',
+            16 => 'ti_2 tinyint(1) NOT NULL',
+            17 => 'ti_3 tinyint(2) NOT NULL',
+            18 => 'si_col smallint NOT NULL',
+            19 => 'si_col_2 smallint unsigned zerofill NOT NULL',
+            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NOT NULL DEFAULT 7',
+            21 => 'bi bigint NOT NULL',
+            22 => 'int_col int NOT NULL',
+            23 => 'int_col_2 integer NOT NULL',
+            24 => 'numeric_col numeric NOT NULL',
+            25 => 'float_col float NOT NULL',
+            26 => 'float_2 float(10, 2) NOT NULL',
+            27 => 'float_3 float(8) NOT NULL',
+            28 => 'double_col double NOT NULL',
+            29 => 'double_p double precision(10,2) NOT NULL',
+            30 => 'double_p_2 double precision NOT NULL',
+            31 => 'real_col real NOT NULL',
+            32 => 'date_col date NOT NULL',
+            33 => 'time_col time NOT NULL',
+            34 => 'datetime_col datetime NOT NULL',
+            35 => 'timestamp_col timestamp NOT NULL',
+            36 => 'year_col year NOT NULL',
             37 => 'json_col json NOT NULL',
             38 => 'json_col_def json NOT NULL DEFAULT \'[]\'',
             39 => 'json_col_def_2 json NOT NULL DEFAULT \'[]\'',
-            40 => 'blob_def blob NULL DEFAULT \'the blob\'',
-            41 => 'text_def text NULL DEFAULT \'the text\'',
+            40 => 'blob_def blob NOT NULL DEFAULT \'the blob\'',
+            41 => 'text_def text NOT NULL DEFAULT \'the text\'',
             42 => 'json_def json NOT NULL DEFAULT \'{"a":"b"}\'',
         ]);
     }
diff --git a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000001_change_table_editcolumns.php b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000001_change_table_editcolumns.php
index 239c0a9b..081ebbd2 100644
--- a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000001_change_table_editcolumns.php
+++ b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000001_change_table_editcolumns.php
@@ -7,16 +7,16 @@ class m200000_000001_change_table_editcolumns extends \yii\db\Migration
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN first_name varchar(255) NULL DEFAULT NULL AFTER tag')->execute();
+        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN first_name varchar(255) NOT NULL AFTER tag')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN json_col_def_n json NOT NULL DEFAULT \'[]\' AFTER numeric_col')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN json_col_def_n_2 json NOT NULL DEFAULT \'[]\'')->execute();
         $this->alterColumn('{{%editcolumns}}', 'name', $this->string(255)->notNull()->defaultValue('Horse-2'));
         $this->alterColumn('{{%editcolumns}}', 'string_col', $this->text()->null()->defaultValue(null));
-        $this->alterColumn('{{%editcolumns}}', 'dec_col', $this->decimal(12,2)->null()->defaultValue("3.14"));
+        $this->alterColumn('{{%editcolumns}}', 'dec_col', $this->decimal(12,2)->notNull()->defaultValue("3.14"));
         $this->alterColumn('{{%editcolumns}}', 'str_col_def', $this->string(3)->notNull());
         $this->alterColumn('{{%editcolumns}}', 'json_col', $this->text()->notNull()->defaultValue('fox jumps over dog'));
         $this->alterColumn('{{%editcolumns}}', 'json_col_2', 'json NOT NULL DEFAULT \'[]\'');
-        $this->alterColumn('{{%editcolumns}}', 'numeric_col', $this->double()->null()->defaultValue(null));
+        $this->alterColumn('{{%editcolumns}}', 'numeric_col', $this->double()->notNull());
     }
 
     public function down()
diff --git a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php
index a53b1995..e14e1be4 100644
--- a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php
+++ b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000002_create_table_newcolumns.php
@@ -10,11 +10,11 @@ public function up()
         $this->createTable('{{%newcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL',
-            'last_name' => $this->text()->null()->defaultValue(null),
-            1 => 'dec_col decimal(12,4) NULL DEFAULT NULL',
+            'last_name' => $this->text()->notNull(),
+            1 => 'dec_col decimal(12,4) NOT NULL',
             2 => 'json_col json NOT NULL',
-            3 => 'varchar_col varchar(5) NULL DEFAULT NULL',
-            4 => 'numeric_col double precision NULL DEFAULT NULL',
+            3 => 'varchar_col varchar(5) NOT NULL',
+            4 => 'numeric_col double precision NOT NULL',
             5 => 'json_col_def_n json NOT NULL DEFAULT \'[]\'',
         ]);
     }
diff --git a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
index 7c0b936f..746b4549 100644
--- a/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/edit_column/maria/app/migrations_maria_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function up()
         $this->createTable('{{%pristines}}', [
             0 => 'custom_id_col integer primary key auto_increment NOT NULL',
             1 => 'name text NOT NULL',
-            'tag' => $this->text()->null()->defaultValue('4 leg'),
-            2 => 'new_col varchar(17) NULL DEFAULT NULL',
-            3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
-            4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
-            5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull()->defaultValue('4 leg'),
+            2 => 'new_col varchar(17) NOT NULL',
+            3 => 'col_5 decimal(12,4) NOT NULL',
+            4 => 'col_6 decimal(11,2) NOT NULL',
+            5 => 'col_7 decimal(10,2) NOT NULL',
             6 => 'col_8 json NOT NULL',
-            7 => 'col_9 varchar(9) NULL DEFAULT NULL',
-            8 => 'col_10 varchar(10) NULL DEFAULT NULL',
-            9 => 'col_11 text NULL DEFAULT NULL',
-            10 => 'price decimal(10,2) NULL DEFAULT 0 COMMENT \'price in EUR\'',
+            7 => 'col_9 varchar(9) NOT NULL',
+            8 => 'col_10 varchar(10) NOT NULL',
+            9 => 'col_11 text NOT NULL',
+            10 => 'price decimal(10,2) NOT NULL DEFAULT 0 COMMENT \'price in EUR\'',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
index 2cda660f..6dfa9ea3 100644
--- a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,48 +9,48 @@ public function up()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => 'string_col varchar(255) NULL DEFAULT NULL',
-            1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
-            2 => 'text_col text NULL',
-            3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
-            4 => 'char_4_col char(4) NULL DEFAULT NULL',
-            5 => 'char_5_col char NULL DEFAULT NULL',
+            0 => 'string_col varchar(255) NOT NULL',
+            1 => 'varchar_col varchar(132) NOT NULL',
+            2 => 'text_col text NOT NULL',
+            3 => 'varchar_4_col varchar(4) NOT NULL',
+            4 => 'char_4_col char(4) NOT NULL',
+            5 => 'char_5_col char NOT NULL',
             6 => 'char_6_col char NOT NULL',
             7 => 'char_7_col char(6) NOT NULL',
-            8 => 'char_8_col char NULL DEFAULT \'d\'',
-            9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
-            10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
-            11 => 'blob_col blob NULL',
-            12 => 'bit_col bit NULL DEFAULT NULL',
-            13 => 'bit_2 bit(1) NULL DEFAULT NULL',
-            14 => 'bit_3 bit(64) NULL DEFAULT NULL',
-            15 => 'ti tinyint NULL DEFAULT NULL',
-            16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
-            17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
-            18 => 'si_col smallint NULL DEFAULT NULL',
-            19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
-            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
-            21 => 'bi bigint NULL DEFAULT NULL',
-            22 => 'int_col int NULL DEFAULT NULL',
-            23 => 'int_col_2 integer NULL DEFAULT NULL',
-            24 => 'numeric_col numeric NULL DEFAULT NULL',
-            25 => 'float_col float NULL DEFAULT NULL',
-            26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
-            27 => 'float_3 float(8) NULL DEFAULT NULL',
-            28 => 'double_col double NULL DEFAULT NULL',
-            29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
-            30 => 'double_p_2 double precision NULL DEFAULT NULL',
-            31 => 'real_col real NULL DEFAULT NULL',
-            32 => 'date_col date NULL DEFAULT NULL',
-            33 => 'time_col time NULL DEFAULT NULL',
-            34 => 'datetime_col datetime NULL DEFAULT NULL',
-            35 => 'timestamp_col timestamp NULL DEFAULT NULL',
-            36 => 'year_col year NULL DEFAULT NULL',
+            8 => 'char_8_col char NOT NULL DEFAULT \'d\'',
+            9 => 'decimal_col decimal(12,3) NOT NULL',
+            10 => 'varbinary_col varbinary(5) NOT NULL',
+            11 => 'blob_col blob NOT NULL',
+            12 => 'bit_col bit NOT NULL',
+            13 => 'bit_2 bit(1) NOT NULL',
+            14 => 'bit_3 bit(64) NOT NULL',
+            15 => 'ti tinyint NOT NULL',
+            16 => 'ti_2 tinyint(1) NOT NULL',
+            17 => 'ti_3 tinyint(2) NOT NULL',
+            18 => 'si_col smallint NOT NULL',
+            19 => 'si_col_2 smallint unsigned zerofill NOT NULL',
+            20 => 'mi mediumint(10) unsigned zerofill comment "comment" NOT NULL DEFAULT 7',
+            21 => 'bi bigint NOT NULL',
+            22 => 'int_col int NOT NULL',
+            23 => 'int_col_2 integer NOT NULL',
+            24 => 'numeric_col numeric NOT NULL',
+            25 => 'float_col float NOT NULL',
+            26 => 'float_2 float(10, 2) NOT NULL',
+            27 => 'float_3 float(8) NOT NULL',
+            28 => 'double_col double NOT NULL',
+            29 => 'double_p double precision(10,2) NOT NULL',
+            30 => 'double_p_2 double precision NOT NULL',
+            31 => 'real_col real NOT NULL',
+            32 => 'date_col date NOT NULL',
+            33 => 'time_col time NOT NULL',
+            34 => 'datetime_col datetime NOT NULL',
+            35 => 'timestamp_col timestamp NOT NULL',
+            36 => 'year_col year NOT NULL',
             37 => 'json_col json NOT NULL',
             38 => 'json_col_def json NOT NULL',
             39 => 'json_col_def_2 json NOT NULL',
-            40 => 'blob_def blob NULL',
-            41 => 'text_def text NULL',
+            40 => 'blob_def blob NOT NULL',
+            41 => 'text_def text NOT NULL',
             42 => 'json_def json NOT NULL',
         ]);
     }
diff --git a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000001_change_table_editcolumns.php b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000001_change_table_editcolumns.php
index b4d63bd3..99285606 100644
--- a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000001_change_table_editcolumns.php
+++ b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000001_change_table_editcolumns.php
@@ -7,16 +7,16 @@ class m200000_000001_change_table_editcolumns extends \yii\db\Migration
 {
     public function up()
     {
-        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN first_name varchar(255) NULL DEFAULT NULL AFTER tag')->execute();
+        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN first_name varchar(255) NOT NULL AFTER tag')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN json_col_def_n json NOT NULL AFTER numeric_col')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN json_col_def_n_2 json NOT NULL')->execute();
         $this->alterColumn('{{%editcolumns}}', 'name', $this->string(255)->notNull()->defaultValue('Horse-2'));
         $this->alterColumn('{{%editcolumns}}', 'string_col', $this->text()->null());
-        $this->alterColumn('{{%editcolumns}}', 'dec_col', $this->decimal(12,2)->null()->defaultValue("3.14"));
+        $this->alterColumn('{{%editcolumns}}', 'dec_col', $this->decimal(12,2)->notNull()->defaultValue("3.14"));
         $this->alterColumn('{{%editcolumns}}', 'str_col_def', $this->string(3)->notNull());
         $this->alterColumn('{{%editcolumns}}', 'json_col', $this->text()->notNull());
         $this->alterColumn('{{%editcolumns}}', 'json_col_2', 'json NOT NULL');
-        $this->alterColumn('{{%editcolumns}}', 'numeric_col', $this->double()->null()->defaultValue(null));
+        $this->alterColumn('{{%editcolumns}}', 'numeric_col', $this->double()->notNull());
     }
 
     public function down()
diff --git a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
index 50881e9d..96f3acdc 100644
--- a/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/edit_column/mysql/app/migrations_mysql_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function up()
         $this->createTable('{{%pristines}}', [
             0 => 'custom_id_col integer primary key auto_increment NOT NULL',
             1 => 'name text NOT NULL',
-            'tag' => $this->text()->null(),
-            2 => 'new_col varchar(17) NULL DEFAULT NULL',
-            3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
-            4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
-            5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull(),
+            2 => 'new_col varchar(17) NOT NULL',
+            3 => 'col_5 decimal(12,4) NOT NULL',
+            4 => 'col_6 decimal(11,2) NOT NULL',
+            5 => 'col_7 decimal(10,2) NOT NULL',
             6 => 'col_8 json NOT NULL',
-            7 => 'col_9 varchar(9) NULL DEFAULT NULL',
-            8 => 'col_10 varchar(10) NULL DEFAULT NULL',
-            9 => 'col_11 text NULL',
-            10 => 'price decimal(10,2) NULL DEFAULT 0 COMMENT \'price in EUR\'',
+            7 => 'col_9 varchar(9) NOT NULL',
+            8 => 'col_10 varchar(10) NOT NULL',
+            9 => 'col_11 text NOT NULL',
+            10 => 'price decimal(10,2) NOT NULL DEFAULT 0 COMMENT \'price in EUR\'',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
index e0cac52a..b3239c59 100644
--- a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
+++ b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000000_create_table_alldbdatatypes.php
@@ -9,99 +9,99 @@ public function safeUp()
     {
         $this->createTable('{{%alldbdatatypes}}', [
             'id' => $this->bigPrimaryKey(),
-            0 => '"string_col" varchar NULL DEFAULT NULL',
-            1 => '"varchar_col" varchar NULL DEFAULT NULL',
-            2 => '"text_col" text NULL DEFAULT NULL',
-            3 => '"text_col_array" text[] NULL DEFAULT NULL',
-            4 => '"varchar_4_col" varchar(4) NULL DEFAULT NULL',
-            5 => '"varchar_5_col" varchar(5) NULL DEFAULT NULL',
-            6 => '"char_4_col" char(4) NULL DEFAULT NULL',
-            7 => '"char_5_col" char NULL DEFAULT NULL',
+            0 => '"string_col" varchar NOT NULL',
+            1 => '"varchar_col" varchar NOT NULL',
+            2 => '"text_col" text NOT NULL',
+            3 => '"text_col_array" text[] NOT NULL',
+            4 => '"varchar_4_col" varchar(4) NOT NULL',
+            5 => '"varchar_5_col" varchar(5) NOT NULL',
+            6 => '"char_4_col" char(4) NOT NULL',
+            7 => '"char_5_col" char NOT NULL',
             8 => '"char_6_col" char NOT NULL',
             9 => '"char_7_col" char(6) NOT NULL',
-            10 => '"char_8_col" char NULL DEFAULT \'d\'',
-            11 => '"decimal_col" decimal(12,3) NULL DEFAULT NULL',
-            12 => '"bytea_col_2" bytea NULL DEFAULT NULL',
-            13 => '"bit_col" bit NULL DEFAULT NULL',
-            14 => '"bit_2" bit(1) NULL DEFAULT NULL',
-            15 => '"bit_3" bit(64) NULL DEFAULT NULL',
-            16 => '"ti" smallint NULL DEFAULT NULL',
-            17 => '"int2_col" int2 NULL DEFAULT NULL',
+            10 => '"char_8_col" char NOT NULL DEFAULT \'d\'',
+            11 => '"decimal_col" decimal(12,3) NOT NULL',
+            12 => '"bytea_col_2" bytea NOT NULL',
+            13 => '"bit_col" bit NOT NULL',
+            14 => '"bit_2" bit(1) NOT NULL',
+            15 => '"bit_3" bit(64) NOT NULL',
+            16 => '"ti" smallint NOT NULL',
+            17 => '"int2_col" int2 NOT NULL',
             18 => '"smallserial_col" smallserial NOT NULL',
             19 => '"serial2_col" serial2 NOT NULL',
-            20 => '"si_col" smallint NULL DEFAULT NULL',
-            21 => '"si_col_2" smallint NULL DEFAULT NULL',
-            22 => '"bi" bigint NULL DEFAULT NULL',
-            23 => '"bi2" int8 NULL DEFAULT NULL',
-            24 => '"int4_col" int4 NULL DEFAULT NULL',
+            20 => '"si_col" smallint NOT NULL',
+            21 => '"si_col_2" smallint NOT NULL',
+            22 => '"bi" bigint NOT NULL',
+            23 => '"bi2" int8 NOT NULL',
+            24 => '"int4_col" int4 NOT NULL',
             25 => '"bigserial_col" bigserial NOT NULL',
             26 => '"bigserial_col_2" serial8 NOT NULL',
-            27 => '"int_col" int NULL DEFAULT NULL',
-            28 => '"int_col_2" integer NULL DEFAULT NULL',
-            29 => '"numeric_col" numeric NULL DEFAULT NULL',
-            30 => '"numeric_col_2" numeric(10) NULL DEFAULT NULL',
-            31 => '"numeric_col_3" numeric(10,2) NULL DEFAULT NULL',
-            32 => '"double_p_2" double precision NULL DEFAULT NULL',
-            33 => '"double_p_3" double precision NULL DEFAULT NULL',
-            34 => '"real_col" real NULL DEFAULT NULL',
-            35 => '"float4_col" float4 NULL DEFAULT NULL',
-            36 => '"date_col" date NULL DEFAULT NULL',
-            37 => '"time_col" time NULL DEFAULT NULL',
-            38 => '"time_col_2" time with time zone NULL DEFAULT NULL',
-            39 => '"time_col_3" time without time zone NULL DEFAULT NULL',
-            40 => '"time_col_4" time(3) without time zone NULL DEFAULT NULL',
-            41 => '"timetz_col" timetz NULL DEFAULT NULL',
-            42 => '"timetz_col_2" timetz(3) NULL DEFAULT NULL',
-            43 => '"timestamp_col" timestamp NULL DEFAULT NULL',
-            44 => '"timestamp_col_2" timestamp with time zone NULL DEFAULT NULL',
-            45 => '"timestamp_col_3" timestamp without time zone NULL DEFAULT NULL',
-            46 => '"timestamp_col_4" timestamp(3) without time zone NULL DEFAULT NULL',
-            47 => '"timestamptz_col" timestamptz NULL DEFAULT NULL',
-            48 => '"timestamptz_col_2" timestamptz(3) NULL DEFAULT NULL',
-            49 => '"date2" date NULL DEFAULT NULL',
-            50 => '"timestamp_col_z" timestamp NULL DEFAULT NULL',
-            51 => '"bit_varying" bit varying NULL DEFAULT NULL',
-            52 => '"bit_varying_n" bit varying(8) NULL DEFAULT NULL',
-            53 => '"bit_varying_n_2" varbit NULL DEFAULT NULL',
-            54 => '"bit_varying_n_3" varbit(3) NULL DEFAULT NULL',
-            55 => '"bool_col" boolean NULL DEFAULT NULL',
-            56 => '"bool_col_2" bool NULL DEFAULT NULL',
-            57 => '"box_col" box NULL DEFAULT NULL',
-            58 => '"character_col" character NULL DEFAULT NULL',
-            59 => '"character_n" character(12) NULL DEFAULT NULL',
-            60 => '"character_varying" character varying NULL DEFAULT NULL',
-            61 => '"character_varying_n" character varying(12) NULL DEFAULT NULL',
+            27 => '"int_col" int NOT NULL',
+            28 => '"int_col_2" integer NOT NULL',
+            29 => '"numeric_col" numeric NOT NULL',
+            30 => '"numeric_col_2" numeric(10) NOT NULL',
+            31 => '"numeric_col_3" numeric(10,2) NOT NULL',
+            32 => '"double_p_2" double precision NOT NULL',
+            33 => '"double_p_3" double precision NOT NULL',
+            34 => '"real_col" real NOT NULL',
+            35 => '"float4_col" float4 NOT NULL',
+            36 => '"date_col" date NOT NULL',
+            37 => '"time_col" time NOT NULL',
+            38 => '"time_col_2" time with time zone NOT NULL',
+            39 => '"time_col_3" time without time zone NOT NULL',
+            40 => '"time_col_4" time(3) without time zone NOT NULL',
+            41 => '"timetz_col" timetz NOT NULL',
+            42 => '"timetz_col_2" timetz(3) NOT NULL',
+            43 => '"timestamp_col" timestamp NOT NULL',
+            44 => '"timestamp_col_2" timestamp with time zone NOT NULL',
+            45 => '"timestamp_col_3" timestamp without time zone NOT NULL',
+            46 => '"timestamp_col_4" timestamp(3) without time zone NOT NULL',
+            47 => '"timestamptz_col" timestamptz NOT NULL',
+            48 => '"timestamptz_col_2" timestamptz(3) NOT NULL',
+            49 => '"date2" date NOT NULL',
+            50 => '"timestamp_col_z" timestamp NOT NULL',
+            51 => '"bit_varying" bit varying NOT NULL',
+            52 => '"bit_varying_n" bit varying(8) NOT NULL',
+            53 => '"bit_varying_n_2" varbit NOT NULL',
+            54 => '"bit_varying_n_3" varbit(3) NOT NULL',
+            55 => '"bool_col" boolean NOT NULL',
+            56 => '"bool_col_2" bool NOT NULL',
+            57 => '"box_col" box NOT NULL',
+            58 => '"character_col" character NOT NULL',
+            59 => '"character_n" character(12) NOT NULL',
+            60 => '"character_varying" character varying NOT NULL',
+            61 => '"character_varying_n" character varying(12) NOT NULL',
             62 => '"json_col" json NOT NULL',
             63 => '"jsonb_col" jsonb NOT NULL',
             64 => '"json_col_def" json NOT NULL DEFAULT \'[]\'',
             65 => '"json_col_def_2" json NOT NULL DEFAULT \'[]\'',
-            66 => '"bytea_def" bytea NULL DEFAULT \'the bytea blob default\'',
-            67 => '"text_def" text NULL DEFAULT \'the text\'',
+            66 => '"bytea_def" bytea NOT NULL DEFAULT \'the bytea blob default\'',
+            67 => '"text_def" text NOT NULL DEFAULT \'the text\'',
             68 => '"json_def" json NOT NULL DEFAULT \'{"a":"b"}\'',
             69 => '"jsonb_def" jsonb NOT NULL DEFAULT \'{"ba":"bb"}\'',
-            70 => '"cidr_col" cidr NULL DEFAULT NULL',
-            71 => '"circle_col" circle NULL DEFAULT NULL',
-            72 => '"date_col_z" date NULL DEFAULT NULL',
-            73 => '"float8_col" float8 NULL DEFAULT NULL',
-            74 => '"inet_col" inet NULL DEFAULT NULL',
-            75 => '"interval_col" interval NULL DEFAULT NULL',
-            76 => '"interval_col_2" interval year NULL DEFAULT NULL',
-            77 => '"interval_col_3" interval day to second(3) NULL DEFAULT NULL',
-            78 => '"line_col" line NULL DEFAULT NULL',
-            79 => '"lseg_col" lseg NULL DEFAULT NULL',
-            80 => '"macaddr_col" macaddr NULL DEFAULT NULL',
-            81 => '"money_col" money NULL DEFAULT NULL',
-            82 => '"path_col" path NULL DEFAULT NULL',
-            83 => '"pg_lsn_col" pg_lsn NULL DEFAULT NULL',
-            84 => '"point_col" point NULL DEFAULT NULL',
-            85 => '"polygon_col" polygon NULL DEFAULT NULL',
+            70 => '"cidr_col" cidr NOT NULL',
+            71 => '"circle_col" circle NOT NULL',
+            72 => '"date_col_z" date NOT NULL',
+            73 => '"float8_col" float8 NOT NULL',
+            74 => '"inet_col" inet NOT NULL',
+            75 => '"interval_col" interval NOT NULL',
+            76 => '"interval_col_2" interval year NOT NULL',
+            77 => '"interval_col_3" interval day to second(3) NOT NULL',
+            78 => '"line_col" line NOT NULL',
+            79 => '"lseg_col" lseg NOT NULL',
+            80 => '"macaddr_col" macaddr NOT NULL',
+            81 => '"money_col" money NOT NULL',
+            82 => '"path_col" path NOT NULL',
+            83 => '"pg_lsn_col" pg_lsn NOT NULL',
+            84 => '"point_col" point NOT NULL',
+            85 => '"polygon_col" polygon NOT NULL',
             86 => '"serial_col" serial NOT NULL',
             87 => '"serial4_col" serial4 NOT NULL',
-            88 => '"tsquery_col" tsquery NULL DEFAULT NULL',
-            89 => '"tsvector_col" tsvector NULL',
-            90 => '"txid_snapshot_col" txid_snapshot NULL DEFAULT NULL',
-            91 => '"uuid_col" uuid NULL DEFAULT NULL',
-            92 => '"xml_col" xml NULL DEFAULT NULL',
+            88 => '"tsquery_col" tsquery NOT NULL',
+            89 => '"tsvector_col" tsvector NOT NULL',
+            90 => '"txid_snapshot_col" txid_snapshot NOT NULL',
+            91 => '"uuid_col" uuid NOT NULL',
+            92 => '"xml_col" xml NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000001_change_table_editcolumns.php b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000001_change_table_editcolumns.php
index f1890895..fdf46318 100644
--- a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000001_change_table_editcolumns.php
+++ b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000001_change_table_editcolumns.php
@@ -7,10 +7,10 @@ class m200000_000001_change_table_editcolumns extends \yii\db\Migration
 {
     public function safeUp()
     {
-        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN "first_name" varchar NULL DEFAULT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN "first_name" varchar NOT NULL')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN "json_col_def_n" json NOT NULL DEFAULT \'[]\'')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN "json_col_def_n_2" json NOT NULL DEFAULT \'[]\'')->execute();
-        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN "text_col_array" text[] NULL DEFAULT NULL')->execute();
+        $this->db->createCommand('ALTER TABLE {{%editcolumns}} ADD COLUMN "text_col_array" text[] NOT NULL')->execute();
         $this->db->createCommand('ALTER TABLE {{%editcolumns}} ALTER COLUMN "name" SET DATA TYPE varchar(254)')->execute();
         $this->alterColumn('{{%editcolumns}}', 'name', "SET DEFAULT 'Horse-2'");
         $this->alterColumn('{{%editcolumns}}', 'string_col', 'text NULL USING "string_col"::text');
diff --git a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php
index 4bd08302..b48b6cfd 100644
--- a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php
+++ b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000002_create_table_newcolumns.php
@@ -10,15 +10,15 @@ public function safeUp()
         $this->createTable('{{%newcolumns}}', [
             'id' => $this->primaryKey(),
             0 => '"name" varchar NOT NULL',
-            1 => '"first_name" varchar NULL DEFAULT NULL',
-            'last_name' => $this->text()->null()->defaultValue(null),
-            2 => '"dec_col" decimal(12,4) NULL DEFAULT NULL',
+            1 => '"first_name" varchar NOT NULL',
+            'last_name' => $this->text()->notNull(),
+            2 => '"dec_col" decimal(12,4) NOT NULL',
             3 => '"json_col" json NOT NULL',
-            4 => '"varchar_col" varchar NULL DEFAULT NULL',
-            5 => '"numeric_col" double precision NULL DEFAULT NULL',
+            4 => '"varchar_col" varchar NOT NULL',
+            5 => '"numeric_col" double precision NOT NULL',
             6 => '"json_col_def_n" json NOT NULL DEFAULT \'[]\'',
             7 => '"json_col_def_n_2" json NOT NULL DEFAULT \'[]\'',
-            8 => '"text_col_array" text[] NULL DEFAULT NULL',
+            8 => '"text_col_array" text[] NOT NULL',
         ]);
     }
 
diff --git a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
index 7fa8a01f..e47cd70d 100644
--- a/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
+++ b/tests/specs/x_db_type/edit_column/pgsql/app/migrations_pgsql_db/m200000_000003_create_table_pristines.php
@@ -10,16 +10,16 @@ public function safeUp()
         $this->createTable('{{%pristines}}', [
             0 => '"custom_id_col" serial primary key NOT NULL',
             1 => '"name" text NOT NULL',
-            'tag' => $this->text()->null()->defaultValue('4 leg'),
-            2 => '"new_col" varchar NULL DEFAULT NULL',
-            3 => '"col_5" decimal(12,4) NULL DEFAULT NULL',
-            4 => '"col_6" decimal(11,2) NULL DEFAULT NULL',
-            5 => '"col_7" decimal(10,2) NULL DEFAULT NULL',
+            'tag' => $this->text()->notNull()->defaultValue('4 leg'),
+            2 => '"new_col" varchar NOT NULL',
+            3 => '"col_5" decimal(12,4) NOT NULL',
+            4 => '"col_6" decimal(11,2) NOT NULL',
+            5 => '"col_7" decimal(10,2) NOT NULL',
             6 => '"col_8" json NOT NULL',
-            7 => '"col_9" varchar NULL DEFAULT NULL',
-            8 => '"col_10" varchar NULL DEFAULT NULL',
-            9 => '"col_11" text NULL DEFAULT NULL',
-            10 => '"price" decimal(10,2) NULL DEFAULT 0',
+            7 => '"col_9" varchar NOT NULL',
+            8 => '"col_10" varchar NOT NULL',
+            9 => '"col_11" text NOT NULL',
+            10 => '"price" decimal(10,2) NOT NULL DEFAULT 0',
         ]);
         $this->addCommentOnColumn('{{%pristines}}', 'price', 'price in EUR');
     }
diff --git a/tests/specs/x_db_type/fresh/mysql/x_db_type_mysql.yaml b/tests/specs/x_db_type/fresh/mysql/x_db_type_mysql.yaml
index 3fad9fba..312a769b 100644
--- a/tests/specs/x_db_type/fresh/mysql/x_db_type_mysql.yaml
+++ b/tests/specs/x_db_type/fresh/mysql/x_db_type_mysql.yaml
@@ -305,6 +305,7 @@ components:
           default: Horse-2
         tag:
           type: string
+          nullable: true
         first_name:
           type: string
           x-db-type: varchar(255)
diff --git a/tests/specs/x_db_type/fresh/pgsql/x_db_type_pgsql.yaml b/tests/specs/x_db_type/fresh/pgsql/x_db_type_pgsql.yaml
index 15233c63..b7261cb7 100644
--- a/tests/specs/x_db_type/fresh/pgsql/x_db_type_pgsql.yaml
+++ b/tests/specs/x_db_type/fresh/pgsql/x_db_type_pgsql.yaml
@@ -489,6 +489,7 @@ components:
           default: Horse-2
         tag:
           type: string
+          nullable: true
         first_name:
           type: string
           x-db-type: varchar
@@ -499,6 +500,7 @@ components:
           type: string
           x-db-type: decimal(12,2)
           default: 3.14
+          nullable: true
         str_col_def:
           type: string
           x-db-type: varchar
diff --git a/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Alldbdatatype.php b/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Alldbdatatype.php
index dbbd7ebc..b3e7f07e 100644
--- a/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Alldbdatatype.php
+++ b/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Alldbdatatype.php
@@ -75,7 +75,7 @@ public function rules()
             'json_def_default' => [['json_def'], 'default', 'value' => [
                 'a' => 'b',
             ]],
-            'required' => [['char_6_col', 'char_7_col'], 'required'],
+            'required' => [['char_6_col'], 'required'],
             'string_col_string' => [['string_col'], 'string', 'max' => 255],
             'varchar_col_string' => [['varchar_col'], 'string', 'max' => 132],
             'text_col_string' => [['text_col'], 'string'],
diff --git a/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Editcolumn.php b/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Editcolumn.php
index acaa29cf..cf1e4183 100644
--- a/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Editcolumn.php
+++ b/tests/specs/x_db_type/rules_and_more/maria/app/models/mariamodel/base/Editcolumn.php
@@ -40,7 +40,7 @@ public function rules()
             'json_col_2_default' => [['json_col_2'], 'default', 'value' => []],
             'json_col_def_n_default' => [['json_col_def_n'], 'default', 'value' => []],
             'json_col_def_n_2_default' => [['json_col_def_n_2'], 'default', 'value' => []],
-            'required' => [['name', 'str_col_def', 'json_col', 'json_col_2'], 'required'],
+            'required' => [['name'], 'required'],
             'name_string' => [['name'], 'string', 'max' => 254],
             'tag_string' => [['tag'], 'string'],
             'first_name_string' => [['first_name'], 'string', 'max' => 255],
diff --git a/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Alldbdatatype.php b/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Alldbdatatype.php
index a9e08518..1f2b58b1 100644
--- a/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Alldbdatatype.php
+++ b/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Alldbdatatype.php
@@ -75,7 +75,7 @@ public function rules()
             'json_def_default' => [['json_def'], 'default', 'value' => [
                 'a' => 'b',
             ]],
-            'required' => [['char_6_col', 'char_7_col'], 'required'],
+            'required' => [['char_6_col'], 'required'],
             'string_col_string' => [['string_col'], 'string', 'max' => 255],
             'varchar_col_string' => [['varchar_col'], 'string', 'max' => 132],
             'text_col_string' => [['text_col'], 'string'],
diff --git a/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Editcolumn.php b/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Editcolumn.php
index fe2d46c5..8c8faae4 100644
--- a/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Editcolumn.php
+++ b/tests/specs/x_db_type/rules_and_more/mysql/app/models/base/Editcolumn.php
@@ -40,7 +40,7 @@ public function rules()
             'json_col_2_default' => [['json_col_2'], 'default', 'value' => []],
             'json_col_def_n_default' => [['json_col_def_n'], 'default', 'value' => []],
             'json_col_def_n_2_default' => [['json_col_def_n_2'], 'default', 'value' => []],
-            'required' => [['name', 'str_col_def', 'json_col', 'json_col_2'], 'required'],
+            'required' => [['name'], 'required'],
             'name_string' => [['name'], 'string', 'max' => 254],
             'tag_string' => [['tag'], 'string'],
             'first_name_string' => [['first_name'], 'string', 'max' => 255],
diff --git a/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Alldbdatatype.php b/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Alldbdatatype.php
index c1cdc2f2..2f88f15c 100644
--- a/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Alldbdatatype.php
+++ b/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Alldbdatatype.php
@@ -127,7 +127,7 @@ public function rules()
             'jsonb_def_default' => [['jsonb_def'], 'default', 'value' => [
                 'ba' => 'bb',
             ]],
-            'required' => [['char_6_col', 'char_7_col', 'smallserial_col', 'serial2_col', 'bigserial_col', 'bigserial_col_2', 'serial_col', 'serial4_col'], 'required'],
+            'required' => [['char_6_col'], 'required'],
             'string_col_string' => [['string_col'], 'string'],
             'varchar_col_string' => [['varchar_col'], 'string'],
             'text_col_string' => [['text_col'], 'string'],
diff --git a/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Editcolumn.php b/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Editcolumn.php
index 4cb00fee..e938c2ca 100644
--- a/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Editcolumn.php
+++ b/tests/specs/x_db_type/rules_and_more/pgsql/app/models/pgsqlmodel/base/Editcolumn.php
@@ -41,7 +41,7 @@ public function rules()
             'json_col_2_default' => [['json_col_2'], 'default', 'value' => []],
             'json_col_def_n_default' => [['json_col_def_n'], 'default', 'value' => []],
             'json_col_def_n_2_default' => [['json_col_def_n_2'], 'default', 'value' => []],
-            'required' => [['name', 'str_col_def', 'json_col', 'json_col_2', 'numeric_col'], 'required'],
+            'required' => [['name'], 'required'],
             'name_string' => [['name'], 'string', 'max' => 254],
             'tag_string' => [['tag'], 'string'],
             'first_name_string' => [['first_name'], 'string'],
diff --git a/tests/unit/XDbTypeTest.php b/tests/unit/XDbTypeTest.php
index 2f8149d3..8cb22ff0 100644
--- a/tests/unit/XDbTypeTest.php
+++ b/tests/unit/XDbTypeTest.php
@@ -199,7 +199,7 @@ private function createTableForEditColumns()
             'name' => 'varchar(255) not null default \'Horse\'',
             'tag' => 'text null',
             'string_col' => 'string not null',
-            'dec_col' => 'decimal(12, 4)',
+            'dec_col' => 'decimal(12, 4) null',
             'str_col_def' => 'string default \'hi there\'',
             'json_col' => 'json', // json is jsonb in Pgsql via Yii Pgsql Schema
             'json_col_2' => 'json',

From f1bba1e24b061a0a1ac4efad1f12f6c14ac591fa Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Tue, 11 Mar 2025 07:22:03 +0530
Subject: [PATCH 08/12] Change lot of tests 5 - Fix failing tests

---
 .../m200000_000001_create_table_editcolumns.php               | 2 +-
 .../m200000_000001_create_table_editcolumns.php               | 2 +-
 .../m200000_000001_create_table_editcolumns.php               | 4 ++--
 .../m200000_000001_create_table_editcolumns.php               | 2 +-
 .../m200000_000001_create_table_editcolumns.php               | 2 +-
 .../m200000_000001_create_table_editcolumns.php               | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
index 4c649990..7e778e54 100644
--- a/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/fresh/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->notNull(),
+            'tag' => $this->text()->null()->defaultValue(null),
             1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
             2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
diff --git a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
index 15954d2a..f0d82b30 100644
--- a/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/fresh/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->notNull(),
+            'tag' => $this->text()->null(),
             1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null(),
             2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
diff --git a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
index 040061dd..9844a67b 100644
--- a/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/fresh/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
@@ -10,10 +10,10 @@ public function safeUp()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => '"name" varchar(254) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->notNull(),
+            'tag' => $this->text()->null()->defaultValue(null),
             1 => '"first_name" varchar NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
-            2 => '"dec_col" decimal(12,2) NOT NULL DEFAULT 3.14',
+            2 => '"dec_col" decimal(12,2) NULL DEFAULT 3.14',
             3 => '"str_col_def" varchar NOT NULL',
             4 => '"json_col" text NOT NULL DEFAULT \'fox jumps over dog\'',
             5 => '"json_col_2" jsonb NOT NULL DEFAULT \'[]\'',
diff --git a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
index 4c649990..7e778e54 100644
--- a/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/new_column/maria/app/migrations_maria_db/m200000_000001_create_table_editcolumns.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->notNull(),
+            'tag' => $this->text()->null()->defaultValue(null),
             1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
             2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
diff --git a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
index 15954d2a..f0d82b30 100644
--- a/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/new_column/mysql/app/migrations_mysql_db/m200000_000001_create_table_editcolumns.php
@@ -10,7 +10,7 @@ public function up()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->notNull(),
+            'tag' => $this->text()->null(),
             1 => 'first_name varchar(255) NOT NULL',
             'string_col' => $this->text()->null(),
             2 => 'dec_col decimal(12,2) NOT NULL DEFAULT 3.14',
diff --git a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
index 040061dd..9844a67b 100644
--- a/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
+++ b/tests/specs/x_db_type/new_column/pgsql/app/migrations_pgsql_db/m200000_000001_create_table_editcolumns.php
@@ -10,10 +10,10 @@ public function safeUp()
         $this->createTable('{{%editcolumns}}', [
             'id' => $this->primaryKey(),
             0 => '"name" varchar(254) NOT NULL DEFAULT \'Horse-2\'',
-            'tag' => $this->text()->notNull(),
+            'tag' => $this->text()->null()->defaultValue(null),
             1 => '"first_name" varchar NOT NULL',
             'string_col' => $this->text()->null()->defaultValue(null),
-            2 => '"dec_col" decimal(12,2) NOT NULL DEFAULT 3.14',
+            2 => '"dec_col" decimal(12,2) NULL DEFAULT 3.14',
             3 => '"str_col_def" varchar NOT NULL',
             4 => '"json_col" text NOT NULL DEFAULT \'fox jumps over dog\'',
             5 => '"json_col_2" jsonb NOT NULL DEFAULT \'[]\'',

From 5e0b75464798094eb69676d9980fa432c584e128 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Wed, 12 Mar 2025 11:45:41 +0530
Subject: [PATCH 09/12] Fix failing test

---
 .../m200000_000000_create_table_payments.php                    | 2 +-
 .../migrations_mysql_db/m200000_000001_create_table_samples.php | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000000_create_table_payments.php b/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000000_create_table_payments.php
index 5579f4e7..7e217a0c 100644
--- a/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000000_create_table_payments.php
+++ b/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000000_create_table_payments.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%payments}}', [
             'id' => $this->primaryKey(),
-            'currency' => $this->text()->null(),
+            'currency' => $this->text()->notNull(),
             'samples' => 'json NOT NULL',
         ]);
     }
diff --git a/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000001_create_table_samples.php b/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000001_create_table_samples.php
index b5b3a86c..5b5a40c1 100644
--- a/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000001_create_table_samples.php
+++ b/tests/specs/issue_fix/23_consider_openapi_extension_x_no_relation_also_in_other_pertinent_place/mysql/migrations_mysql_db/m200000_000001_create_table_samples.php
@@ -9,7 +9,7 @@ public function up()
     {
         $this->createTable('{{%samples}}', [
             'id' => $this->primaryKey(),
-            'message' => $this->text()->null(),
+            'message' => $this->text()->notNull(),
         ]);
     }
 

From 95380350d6f6df56d8a99794f03ecf5aa95e6361 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Wed, 12 Mar 2025 18:14:44 +0530
Subject: [PATCH 10/12] Example usage for
 https://github.com/php-openapi/yii2-openapi/pull/98#issuecomment-2717759279

---
 src/lib/FakerStubResolver.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/lib/FakerStubResolver.php b/src/lib/FakerStubResolver.php
index 80eb7ec0..02ea07b9 100644
--- a/src/lib/FakerStubResolver.php
+++ b/src/lib/FakerStubResolver.php
@@ -16,6 +16,7 @@
 use cebe\openapi\ReferenceContext;
 use cebe\openapi\spec\Reference;
 use cebe\openapi\spec\Schema;
+use cebe\openapi\SpecBaseObject;
 use cebe\openapi\SpecObjectInterface;
 use cebe\yii2openapi\lib\exceptions\InvalidDefinitionException;
 use cebe\yii2openapi\lib\items\Attribute;
@@ -329,7 +330,9 @@ public function fakeForObject(SpecObjectInterface $items): string
             if (!empty($prop->properties)) { // nested object
                 $result = $this->{__FUNCTION__}($prop);
             } else {
-                $result = $this->aElementFaker(['items' => $prop->getSerializableData()], $name);
+//                ($prop instanceof SpecBaseObject) && var_dump($prop->rawSpec);
+//                $result = $this->aElementFaker(['items' => $prop->getSerializableData()], $name);
+                $result = $this->aElementFaker(['items' => $prop->rawSpec], $name);
             }
             $props .= '\'' . $name . '\' => ' . $result . ',' . PHP_EOL;
         }
@@ -358,7 +361,7 @@ public function handleOneOf(SpecObjectInterface $items, int $count): string
         foreach ($items->oneOf as $key => $aDataType) {
             /** @var Schema|Reference $aDataType */
 
-            $inp = $aDataType instanceof Reference ? $aDataType : ['items' => $aDataType->getSerializableData()];
+            $inp = $aDataType instanceof Reference ? $aDataType : ['items' => $aDataType->rawSpec];
             $aFaker = $this->aElementFaker($inp, $this->attribute->columnName);
             $result .= '$dataType' . $key . ' = ' . $aFaker . ';';
         }
@@ -403,7 +406,7 @@ public function aElementFaker($data, ?string $columnName = null): ?string
             return '(new ' . $class . ')->generateModel()->attributes';
         }
 
-        $inp = $data instanceof SpecObjectInterface ? $data->getSerializableData() : $data;
+        $inp = $data instanceof SpecObjectInterface ? $data->rawSpec : $data;
         $aElementData = Json::decode(Json::encode($inp));
         $columnName = $columnName ?? 'unnamedProp';
         $compoSchemaData = [

From 47e5e844f0afccd0e50094153a10980f1ccdbbe9 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Wed, 12 Mar 2025 18:15:29 +0530
Subject: [PATCH 11/12] Revert "Example usage for
 https://github.com/php-openapi/yii2-openapi/pull/98#issuecomment-2717759279"

This reverts commit 95380350d6f6df56d8a99794f03ecf5aa95e6361.
---
 src/lib/FakerStubResolver.php | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/lib/FakerStubResolver.php b/src/lib/FakerStubResolver.php
index 02ea07b9..80eb7ec0 100644
--- a/src/lib/FakerStubResolver.php
+++ b/src/lib/FakerStubResolver.php
@@ -16,7 +16,6 @@
 use cebe\openapi\ReferenceContext;
 use cebe\openapi\spec\Reference;
 use cebe\openapi\spec\Schema;
-use cebe\openapi\SpecBaseObject;
 use cebe\openapi\SpecObjectInterface;
 use cebe\yii2openapi\lib\exceptions\InvalidDefinitionException;
 use cebe\yii2openapi\lib\items\Attribute;
@@ -330,9 +329,7 @@ public function fakeForObject(SpecObjectInterface $items): string
             if (!empty($prop->properties)) { // nested object
                 $result = $this->{__FUNCTION__}($prop);
             } else {
-//                ($prop instanceof SpecBaseObject) && var_dump($prop->rawSpec);
-//                $result = $this->aElementFaker(['items' => $prop->getSerializableData()], $name);
-                $result = $this->aElementFaker(['items' => $prop->rawSpec], $name);
+                $result = $this->aElementFaker(['items' => $prop->getSerializableData()], $name);
             }
             $props .= '\'' . $name . '\' => ' . $result . ',' . PHP_EOL;
         }
@@ -361,7 +358,7 @@ public function handleOneOf(SpecObjectInterface $items, int $count): string
         foreach ($items->oneOf as $key => $aDataType) {
             /** @var Schema|Reference $aDataType */
 
-            $inp = $aDataType instanceof Reference ? $aDataType : ['items' => $aDataType->rawSpec];
+            $inp = $aDataType instanceof Reference ? $aDataType : ['items' => $aDataType->getSerializableData()];
             $aFaker = $this->aElementFaker($inp, $this->attribute->columnName);
             $result .= '$dataType' . $key . ' = ' . $aFaker . ';';
         }
@@ -406,7 +403,7 @@ public function aElementFaker($data, ?string $columnName = null): ?string
             return '(new ' . $class . ')->generateModel()->attributes';
         }
 
-        $inp = $data instanceof SpecObjectInterface ? $data->rawSpec : $data;
+        $inp = $data instanceof SpecObjectInterface ? $data->getSerializableData() : $data;
         $aElementData = Json::decode(Json::encode($inp));
         $columnName = $columnName ?? 'unnamedProp';
         $compoSchemaData = [

From a543737997655bd3732f96358dfca64b5e8355d9 Mon Sep 17 00:00:00 2001
From: Sohel Ahmed Mesaniya <sam.wankaner@gmail.com>
Date: Tue, 13 May 2025 16:43:40 +0530
Subject: [PATCH 12/12] Update dependency

---
 composer.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index 115ef883..a906d49b 100644
--- a/composer.json
+++ b/composer.json
@@ -19,7 +19,7 @@
 	},
 	"require": {
 		"php": "^7.4 || ^8.0",
-		"cebe/php-openapi": "^1.7.0",
+		"cebe/php-openapi": "1.8.*",
 		"yiisoft/yii2": "~2.0.48",
 		"yiisoft/yii2-gii": "~2.0.0 | ~2.1.0 | ~2.2.0| ~2.3.0",
 		"laminas/laminas-code": ">=3.4 <=4.13",