File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 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+ ````
You can’t perform that action at this time.
0 commit comments