Last active
April 23, 2022 04:03
-
-
Save neatstudio/ca983384e31f67e3e9001ce2236cbc2d to your computer and use it in GitHub Desktop.
根据functions.php中的ysqlite来衍生的临时创建migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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