laravel 项目迁移_在Laravel迁移

laravel 项目迁移

Before moving forward we need to know some facts about it,

在继续前进之前,我们需要了解一些事实,

  • Resources: In these directories, we have already a js, lang, sass and view page. Where, sass and js file holf their uncompressed, unminified js, CSS, sass file.

    资源:在这些目录中,我们已经有一个js,lang,sass和view页面。 sass和js文件将其未压缩,最小化的js,CSS和sass文件分开。

  • view/welcome.blade.php: Which is already defined in storage/framwork/views/.... (at the bottom of the page: path/welcome.blade.php)

    view / welcome.blade.php:已在storage / framwork / views / ....中定义(在页面底部:path / welcome.blade.php)

在Laravel迁移 (Migration in Laravel)

We are creating migration for creating databases or Database columns in PHPMyAdmin or any other database. After migration it will be automatically creating a database in PHPMyAdmin means we don't have to create again database and it's columns in PHPMyAdmin.

我们正在创建迁移,以在PHPMyAdmin或任何其他数据库中创建数据库或Database列。 迁移后,它将自动在PHPMyAdmin中创建数据库,这意味着我们不必再次创建数据库,并且它是PHPMyAdmin中的列。

Here, we need to create a post-migration table for creating a table column to store, retrieve, edit and update the data, we can take columns name according to our requirement.

在这里,我们需要创建一个迁移后的表,以创建一个表列来存储,检索,编辑和更新数据,我们可以根据需要获取列名。

First, On CMD run this command for creating a migration table,

首先,在CMD上运行此命令以创建迁移表,

    $ php artisan make:migration create_posts_table

Now, you can see this migration file in this path and open it: database/migration/create_posts_table

现在,您可以在此路径中看到此迁移文件并打开它: database / migration / create_posts_table

Migration in Laravel | Step 1

Here, I am declaring a column name in public function up{ // code }

在这里,我在public function up中声明一个列名{//代码}

Example: Code for create_posts_table

示例:create_posts_table的代码

class CreatePostsTable extends Migration
{
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('body');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('posts');
}
}

public function up{}: In this function, we are creating a database schema. It is the blueprint of the table that's why we are writing a Blueprint $table in the Schema.

public function up {} :在此函数中,我们正在创建一个数据库模式。 这就是表的蓝图,这就是我们在Schema中编写Blueprint $ table的原因。

public function down{}: In this function, dropIfExists means to drop the table "posts" if already exists.

public function down {} :在此函数中, dropIfExists表示删除表“ posts”(如果已存在)。

Now, again on CMD: $ php artisan migrate

现在,再次在CMD上: $ php artisan migration

Here, this command is used to migrate the table columns successfully. Every migration table has two classes "UP" and "down".

在此,此命令用于成功迁移表列。 每个迁移表都有两个类“ UP”“ down”

  • "UP" class: This method is used to set execution whenever the migration command is running.

    “ UP”类 :每当运行迁移命令时,此方法用于设置执行。

  • "Down" class: This method is used to set when you want to rollback after migration. You can say that it is the reverse of the "UP" method.

    “ Down”类 :此方法用于设置要在迁移后回滚的时间。 您可以说这与“ UP”方法相反。

Now, after migration, we have a new Posts table in PHPMyAdmin's blog' DB table named 'posts'. Again Here, "Posts" is your table name from where you can store, retrieve, delete and update your data.

现在,在迁移之后,我们在PHPMyAdmin的博客“ DB”表中有了一个名为“ posts”的新Posts表。 在这里, “职位”是您的表名,您可以在其中存储,检索,删除和更新数据。

Migration in Laravel | Step 2

Now, here you can see after the migration database id automatically created in the PHPMyAdmin.

现在,在这里您可以看到在PHPMyAdmin中自动创建的迁移数据库ID。

Conclusion:

结论:

In this article, we have learnt about the migration in Laravel. I hope you understood the concept, we will know more about it in the up coming articles. Have a great day! Happy Learning!

在本文中,我们了解了Laravel中迁移 。 希望您理解这个概念,我们将在以后的文章中进一步了解它。 祝你有美好的一天! 学习愉快!

翻译自: https://www.includehelp.com/laravel/migration.aspx

laravel 项目迁移

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/540561.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python之list对应元素求和

本次分享将讲述如何在Python中对多个list的对应元素求和,前提是每个list的长度一样。比如:a[1,2,3], b[2,3,4], c[3,4,5], 对a,b,c的对应元素求和,输出应为[6,9,12].    方法一:   直接求解,按照对应元素相加的…

[转载] Python中str跟int的转换

参考链接: Python中的类型转换 字符串str转换成int: int_value int(str_value) int转换成字符串str: str_value str(int_value) a100 b666 #int转str类型 print(int转str类型) print(int转str: str(a)) #str转int类型 print(str转int类型…

ot协议是什么_OT的完整形式是什么?

ot协议是什么OT:主题外 (OT: Off Topic) OT is an abbreviation of "Off Topic". OT是“ Off Topic”的缩写 。 It is an expression, which is commonly used in Gmail or messaging platform. It shows that the email that has been sent is irrelev…

[转载] python中字符串编码形式及其所占字节

参考链接: Python中的字节对象与字符串 1.常见字符串编码错误 在使用Python读文件时经常遇到编码问题引起的错误,比如: UnicodeDecodeError: gbk codec cant decode byte 0x80 in position 30: illegal multibyte sequence 遇到这种异…

[AtCoder-ARC073F]Many Moves

题目大意:   有一排n个格子和2枚硬币。   现在有q次任务,每一次要你把其中一枚硬币移到x的位置上,移动1格的代价是1。   两枚硬币不能同时移动,任务必须按次序完成。   现在告诉你两枚硬币初始状态所在的位置a和b&#xf…

ScalavsKotlin

Is Scala better that Kotlin? No..., Is Kotlin better than Scala? No... Scala比Kotlin更好吗? 不...,Kotlin胜过Scala吗? 没有... Both programming languages have their own profits and are for a specific set of development. It…

工业智能相机与基于PC的机器视觉的区别比较

随着科技的日渐成熟,机器视觉得到了飞速发展。由于嵌入式技术的发展,近几年智能相机性能显著提高,越来越多必须依赖于PC处理的应用开始向智能相机平台倾斜。低成本、高可靠性及易于安装维护等优势,使得机器视觉在制造业上的规模性应用越来越普…

[转载] python skimage在图像处理中的用法

参考链接: 在Python中打印单变量和多变量 基于python脚本语言开发的数字图片处理包,比如PIL,Pillow, opencv, scikit-image等。 PIL和Pillow只提供最基础的数字图像处理,功能有限;opencv实际上是一个c库,只是提供了py…

scala元组 数组_Scala中的数组

scala元组 数组Scala中的数组 (Arrays in Scala) An array is a linear data structure with a fixed number of elements. It is a collection that stores a fixed number Arrays in Scalf elements of the same datatype. In Scala, an array is 0 indexed, i.e. the first …

OpenStack —— DevStack一键自动化安装

一、DevStack介绍Devstack目前是支持Ubuntu16.04和CentOS 7,而且Devstack官方建议使用Ubuntu16.04,所以我们使用Ubuntu 16.04进行安装。默认无论是Devstack和OpenStack,都是采用Master的代码进行安装,这样经常会出现,今…

[转载] Python学习笔记——运维和Shell

参考链接: 在C / C,Python,PHP和Java中交换两个变量 目录 什么是运维 运维第一工具-shell编程 shell历史 执行脚本 基本语法 Shell脚本语法 条件测试:test [ if/then/elif/else/fi case/esac for/do/done …

scala java混合_Scala特性混合

scala java混合Scala | 特性混合 (Scala | Trait Mixins ) In Scala, the number of traits can be extended using a class or an abstract class. This is known as Trait Mixins. For extending, only traits, the blend of traits, class or abstract class are valid. If …

Scala铸造

Scala中的类型 (Types in Scala) Type also know as data type tells the compiler about the type of data that is used by the programmer. For example, if we initialize a value or variable as an integer the compiler will free up 4 bytes of memory space and it wi…

/ 卡路里_最大卡路里

/ 卡路里Problem statement: 问题陈述: Shivang is very foodie but he has a diet plan. He has an array of elements indicating the calorie of food he can consume on that day. In his diet plan, he can’t eat on for three consecutive days. But since …

[转载] Python类中的私有变量和公有变量

参考链接: Python中的私有变量 我们这里就直奔主题,不做基础铺垫,默认你有一些Python类的基础,大家在看这篇博客的时候,如果基础知识忘了,可以去菜鸟教程 从一个简单的类开始 class A(): #定义一…

OpenCV探索之路(二十五):制作简易的图像标注小工具

搞图像深度学习的童鞋一定碰过图像数据标注的东西,当我们训练网络时需要训练集数据,但在网上又没有找到自己想要的数据集,这时候就考虑自己制作自己的数据集了,这时就需要对图像进行标注。图像标注是件很枯燥又很费人力物力的一件…

固件的完整形式是什么?

FW:前进 (FW: Forward) FW is an abbreviation of "Forward". FW是“ Forward”的缩写 。 It is an expression, which is commonly used in Gmail or messaging platform. It is also written as FWD or Fwd or Fw. It shows that the email has been s…

[转载] python __slots__ 详解(上篇)

参考链接: Python的__name __(特殊变量) python中的new-style class要求继承Python中的一个内建类型, 一般继承object,也可以继承list或者dict等其他的内建类型。 在python新式类中,可以定义一个变量__slots__,它的作…

委托BegionInvoke和窗体BegionInvoke

委托BegionInvoke是指通过委托方法执行多线程任务,例如: //定义委托成员变量 delegate void dg_DeleAirport(); //指定委托函数 dg_DeleAirport dga AirportBLL.DeleteHistoryTransAirport; //通过BeginInvoke以异步线程方式执行委托函数,可…

图论 弦_混乱的弦

图论 弦Problem statement: 问题陈述: You are provided an input string S and the string "includehelp". You need to figure out all possible subsequences "includehelp" in the string S? Find out the number of ways in which the s…