Skip to content

Instantly share code, notes, and snippets.

@neatstudio
Last active April 23, 2022 04:03
Show Gist options
  • Save neatstudio/ca983384e31f67e3e9001ce2236cbc2d to your computer and use it in GitHub Desktop.
Save neatstudio/ca983384e31f67e3e9001ce2236cbc2d to your computer and use it in GitHub Desktop.
根据functions.php中的ysqlite来衍生的临时创建migration
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTestTable extends Migration
{
public function __construct()
{
ysqlite();
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection('ysqlite')->create('test', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
ysqlite()->insert("insert into test (name) values ('test')");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::connection('ysqlite')->dropIfExists('test');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment