laravel中建表为何要用migration来操作数据库?
本地用的服务器是:wampServer
在www目录下通过composer命令新建了一个laravel5项目,版本是5.1.26
在很多laravel入门教程里都是通过命令来建立数据表,然后进行数据迁移和填充的,这跟直接在phpMyAdmin或Navicat Premium里建立表有什么不同吗?如果是一样的,那么是使用laravel的migration有什么益处吗?
发完这个问题后,了解到JellyBool的laravel系列教程(https://laravist.com/),这里有文字版(https://jellybool.com/),在教程四中找到了答案:
可以将Migration看作一个数据库版本的管理工具,就如git对项目文件的版本管理,可以rollback,reset等(通过php artisan命令查看具体命令)
所以其实用Migration建表跟直接手动创建表是一样的,不同在于使用Migration有额外的管理数据库的功能:回滚/重置/更新等。
回复内容:
本地用的服务器是:wampServer
在www目录下通过composer命令新建了一个laravel5项目,版本是5.1.26
在很多laravel入门教程里都是通过命令来建立数据表,然后进行数据迁移和填充的,这跟直接在phpMyAdmin或Navicat Premium里建立表有什么不同吗?如果是一样的,那么是使用laravel的migration有什么益处吗?
发完这个问题后,了解到JellyBool的laravel系列教程(https://laravist.com/),这里有文字版(https://jellybool.com/),在教程四中找到了答案:
可以将Migration看作一个数据库版本的管理工具,就如git对项目文件的版本管理,可以rollback,reset等(通过php artisan命令查看具体命令)
所以其实用Migration建表跟直接手动创建表是一样的,不同在于使用Migration有额外的管理数据库的功能:回滚/重置/更新等。
使用这个migration
好处就是你可以在你的项目里面直接保留下表的结构信息,并且由于后面的sql实际上是生成的,哪天你不想用mysql换到pqsql, sqlite甚至oracle都会由ORM替你生成建表语句。
然后就是额外提供了一些版本控制方面的东西,看你自己是否会需要这些特性来做出评估了。
当然你也可以完全不用这个工具,用自己的习惯的方式来建表,并没有什么不妥
把schema纳入版本控制, 方便追踪和deploy
并且(只要内容不冲突)可以多人平行开发

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

When developing websites using CraftCMS, you often encounter resource file caching problems, especially when you frequently update CSS and JavaScript files, old versions of files may still be cached by the browser, causing users to not see the latest changes in time. This problem not only affects the user experience, but also increases the difficulty of development and debugging. Recently, I encountered similar troubles in my project, and after some exploration, I found the plugin wiejeben/craft-laravel-mix, which perfectly solved my caching problem.

Laravel provides a comprehensive Auth framework for implementing user login functions, including: Defining user models (Eloquent model), creating login forms (Blade template engine), writing login controllers (inheriting Auth\LoginController), verifying login requests (Auth::attempt) Redirecting after login is successful (redirect) considering security factors: hash passwords, anti-CSRF protection, rate limiting and security headers. In addition, the Auth framework also provides functions such as resetting passwords, registering and verifying emails. For details, please refer to the Laravel documentation: https://laravel.com/doc

To learn Laravel 6, you can get video tutorials from Laracasts (recommended), official documentation and YouTube. Recommended courses include Laracasts’ “Laravel 6 From Beginner to Mastery” and “Official Laravel 6 Tutorial” produced by the official team. When choosing a video course, consider skill level, teaching style, project experience and frequency of updates.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

Laravel and ThinkPHP are both popular PHP frameworks and have their own advantages and disadvantages in development. This article will compare the two in depth, highlighting their architecture, features, and performance differences to help developers make informed choices based on their specific project needs.

In the Laravel framework version selection guide for beginners, this article dives into the version differences of Laravel, designed to assist beginners in making informed choices among many versions. We will focus on the key features of each release, compare their pros and cons, and provide useful advice to help beginners choose the most suitable version of Laravel based on their skill level and project requirements. For beginners, choosing a suitable version of Laravel is crucial because it can significantly impact their learning curve and overall development experience.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.
