Skip to content

Commit b447a26

Browse files
committed
Fix the NOT NULL error when a migration is defined without a default value
1 parent 9d5adae commit b447a26

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/SQLiteMigration.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ private function transformMigration($table, $callback)
5252
if ($usingSqlLite && !$col->nullable) {
5353
$obj['nullable'] = true;
5454
$obj['type'] = $this->mapType($obj['type']);
55+
56+
if (!isset($obj['default'])) {
57+
switch ($obj['type']) {
58+
case 'string':
59+
$obj['default'] = '';
60+
break;
61+
default:
62+
$obj['default'] = null;
63+
break;
64+
}
65+
}
5566
$userInput[] = $obj;
5667

5768
$obj['nullable'] = false;

0 commit comments

Comments
 (0)