jjclane / laravel-sqlite-migrations
一个特性,用于将Laravel迁移转换为SQLite安全迁移。
0.2.0
2023-10-21 04:48 UTC
Requires
- illuminate/database: ^7.0||^8.0||^9.0||^10.0
README
一个特性,用于将Laravel迁移转换为SQLite安全迁移。这可以避免在尝试通过先将列作为可空列添加到现有表中,然后在单独的迁移中修改列时遇到的 "Cannot add a NOT NULL column with default value NULL
" 问题。它还将Laravel数据类型映射到SQLite不支持的数据类型,以避免这个问题。
安装
composer require jjclane/laravel-sqlite-migrations --dev
如何使用
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use JJCLane\SQLiteMigration\TransformMigration; class AddColumnToTable extends Migration { use TransformMigration; /** * Run the migrations. * * @return void */ public function up() { $this->table('table', function (Blueprint $table) { // Normal migrations $table->decimal('my_col', 10, 1)->unsigned()->after('my_other_col'); }); // or if you prefer to be more explicit $this->transformMigration('table', function (Blueprint $table) { // Normal migrations $table->decimal('my_col', 10, 1)->unsigned()->after('my_other_col'); }); } }