Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points of laravel 8 migration files

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, Xiaobian will share with you what are the relevant knowledge points of laravel 8 migration file knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone's reference, I hope you have gained something after reading this article, let's learn about it together.

What is migration file?

Migrating files is actually a version control relative to the database, allowing us to easily define and share some data structures inside the program, usually with a structure of our database, migration can easily generate application data structures. If we have a member added to a field in the local database environment, we can migrate it to operate on it.

There are two types of migration, one is to create the migration, and the other is to write the migration file.

The first digit of the file name is the time.

Let's click on it and have a look.

The other two files are also similar. These are some tables defined by default in laravel 8 framework. If we migrate files here, if we don't need to use these tables (user table, password table, jobs table), it's best to delete them, otherwise we may see the existence of these three tables in the database!!!

Create migration file

Create a book list

id primary key

b_name Title

b_pirce book price

b_num Number of books

artisan scaffold command: name we write create_table_table by default

php artisan make:migration create_book_table

After creation, the name of the file will be preceded by a time

increments ('id ') Method of creating an incrementing id

comment ('comment ') Add comment

string ('field name','length') Create field type is string

integer ('field name') Create field type is int

decimal ('field name'[, length, several decimal places precision]) A type used exclusively to store decimals, default 8,2

$table->charset ='utf8 mb4'; defines character encoding

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report