一、基本操作
1、/database/migrations/ 目录下生成一个php文件,这个文件主要包括两个函数,在up()函数中根据你的需求定义数据库字段
php artisan make:migration create_users_table --create=users
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('username', 32); $table->string('password', 32); $table->string('email')->nullable(); $table->string('salt', 6); $table->string('api_token')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } }
2、执行命令,创建数据库
php artisan migrate
二、文档
https://learnku.com/docs/laravel/6.x/migrations/5173
标签:users,数据库,migrations,Lumen,table,迁移,php,string From: https://www.cnblogs.com/yang-2018/p/17761266.html