Laravel中如何使用Migrations
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,这篇文章主要介绍Laravel中如何使用Migrations,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!Laravel:使用Migrations1、首先利用artisan创建
千家信息网最后更新 2024年09月22日Laravel中如何使用Migrations
这篇文章主要介绍Laravel中如何使用Migrations,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
Laravel:使用Migrations
1、首先利用artisan创建一个可迁移的数据表模板,该命令运行后会在database/migrations目录下生成一个文件
php artisan make:migration create_fees_count_table --create=fees_count
2、生成的文件包含up和down两个方法,其中up中是包含了添加表,添加列,添加索引等等一切的描述,down比较简单,就是删除表,当然里面还可以有一些其他逻辑
3、up中支持的数据表列类型,做个备注,暂时不做翻译
Command | Description |
---|---|
$table->bigIncrements('id'); | Incrementing ID (primary key) using a "UNSIGNED BIG INTEGER" equivalent. |
$table->bigInteger('votes'); | BIGINT equivalent for the database. |
$table->binary('data'); | BLOB equivalent for the database. |
$table->boolean('confirmed'); | BOOLEAN equivalent for the database. |
$table->char('name', 4); | CHAR equivalent with a length. |
$table->date('created_at'); | DATE equivalent for the database. |
$table->dateTime('created_at'); | DATETIME equivalent for the database. |
$table->decimal('amount', 5, 2); | DECIMAL equivalent with a precision and scale. |
$table->double('column', 15, 8); | DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point. |
$table->enum('choices', ['foo', 'bar']); | ENUM equivalent for the database. |
$table->float('amount'); | FLOAT equivalent for the database. |
$table->increments('id'); | Incrementing ID (primary key) using a "UNSIGNED INTEGER" equivalent. |
$table->integer('votes'); | INTEGER equivalent for the database. |
$table->json('options'); | JSON equivalent for the database. |
$table->jsonb('options'); | JSONB equivalent for the database. |
$table->longText('description'); | LONGTEXT equivalent for the database. |
$table->mediumInteger('numbers'); | MEDIUMINT equivalent for the database. |
$table->mediumText('description'); | MEDIUMTEXT equivalent for the database. |
$table->morphs('taggable'); | Adds INTEGER taggable_id and STRING taggable_type. |
$table->nullableTimestamps(); | Same as timestamps(), except allows NULLs. |
$table->rememberToken(); | Adds remember_token as VARCHAR(100) NULL. |
$table->smallInteger('votes'); | SMALLINT equivalent for the database. |
$table->softDeletes(); | Adds deleted_at column for soft deletes. |
$table->string('email'); | VARCHAR equivalent column. |
$table->string('name', 100); | VARCHAR equivalent with a length. |
$table->text('description'); | TEXT equivalent for the database. |
$table->time('sunrise'); | TIME equivalent for the database. |
$table->tinyInteger('numbers'); | TINYINT equivalent for the database. |
$table->timestamp('added_on'); | TIMESTAMP equivalent for the database. |
$table->timestamps(); | Adds created_at and updated_at columns. |
$table->uuid('id'); | UUID equivalent for the database. |
4、表创建完成后,直接执行,由于我之前很多表创建并没有使用php artisan migrate,所以直接运行该命令导致提示部分表存在,所以,我把这个文件转移到database下tmp目录下,命令上添加 --path 'database/tmp',再次运行成功
php artisan migrate
5、数据库中观察即发现表已创建!
以上是"Laravel中如何使用Migrations"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
命令
数据
文件
运行
内容
数据表
目录
篇文章
生成
成功
两个
价值
兴趣
再次
备注
小伙
小伙伴
就是
数据库
方法
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
把网络安全工作纳入重要仪事日程
杭州学软件开发是做什么的
安全代理服务器系统
关于存储酒店信息的数据库
vmware 代理服务器
软件开发公司财务流程
php 数据库类型
数码究极进化 神秘数据库
局域网服务器配置各电脑访问权限
激光尺数据库
表格 公式完成后保留数据库
手机服务器在哪能找到
武汉恒山系列鲲鹏服务器
如何查看本机数据库版本
中学生网络安全绘画手抄报
discuz的数据库
日志服务器管理多台设备
微信清理僵尸粉软件开发
倩女幽魂服务器ip
昌平职业学校网络技术
炸别人服务器怎么判
鑫管家服务器连接不上怎么回事
数据库未打开 仅允许
银行管理系统连接数据库
手动数据库整理软件
ie11 代理服务器
公安网络安全培训计划
网络安全扩展实验
软件开发转正ppt模板
华为sn码服务器查询系统