Skip to content

Commit b9c6804

Browse files
committed
Merge
2 parents b9094a7 + fd04472 commit b9c6804

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Laravel SQLite Migrations
2+
A trait to translate Laravel migrations into SQLite safe migrations.
3+
This avoids the `Cannot add a NOT NULL column with default value NULL` issue that you receive when trying to add a non-nullable column to
4+
an existing table in a migration by initially adding the column as nullable and then modifying the column in a separate migration.
5+
It also maps Laravel datatypes that aren't supported in SQLite to avoid [this](https://github.com/laravel/framework/issues/8840).
6+
7+
8+
## How to use
9+
````php
10+
<?php
11+
12+
use Illuminate\Database\Schema\Blueprint;
13+
use Illuminate\Database\Migrations\Migration;
14+
use JJCLane\SQLiteMigration\TransformMigration;
15+
16+
class AddColumnToTable extends Migration
17+
{
18+
use TransformMigration;
19+
20+
/**
21+
* Run the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function up()
26+
{
27+
$this->table('table', function (Blueprint $table) {
28+
// Normal migrations
29+
$table->decimal('my_col', 10, 1)->unsigned()->after('my_other_col');
30+
});
31+
32+
// or if you prefer to be more explicit
33+
$this->transformMigration('table', function (Blueprint $table) {
34+
// Normal migrations
35+
$table->decimal('my_col', 10, 1)->unsigned()->after('my_other_col');
36+
});
37+
}
38+
}
39+
````

0 commit comments

Comments
 (0)