jjclane/laravel-sqlite-migrations

一个特性,用于将Laravel迁移转换为SQLite安全迁移。

安装次数: 15,706

依赖关系: 0

建议者: 0

安全性: 0

星标: 13

关注者: 3

分支: 4

开放问题: 1

类型:laravel-package

0.2.0 2023-10-21 04:48 UTC

This package is auto-updated.

Last update: 2024-09-21 06:36:19 UTC


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');
        });
    }
}