laravel migrate创建数据表
1,使用 Artisan 命令 make:migration 就可以创建一个新的迁移
php artisan make:migration create_users_table
迁移类包含了两个方法:up
和 down
。up
方法用于新增表,列或者索引到数据库,而 down
方法就是 up
方法的逆操作,和 up
里的操作相反。
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFlightsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('airline');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('flights');
}
}
php artisan migrate
回滚迁移
php artisan migrate:rollback
删除所有表 & 迁移
php artisan migrate:fresh
文章来自 www.sxlenovo.com
使用 Artisan 命令 make:migration
就可以创建一个新的迁移
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端