Skip to main content

Laravel Migration

laravel-migration.jpg
laravel

Introduction

Migration is like an update assurance for your software, allowing the team to quickly change and distribute the software scheme for the application. Usually, migrations are combined with Laravel's schema builder to quickly construct the database schema for your query. If you have ever had to tell a colleague to connect a column individually to their regional database schema, you've faced the issue of database migration solve

The Laravel Schema framework offers agnostic support for the database to build and modify tables across all Laravel's supported database systems.

Generating Migrations

To create a migration, here we will use the make: migration Artisan command:

PHP artisan make: migration message_you_want_to_remember

Place the latest transfer in your application/migrations folder. Which name of the transfer file includes a timestamp allowing Laravel to decide the migration order.

The terms —table and —create can be used to signify the position name, whether a new column will be created by the migrate. These options pre-fill the created stub migration file with the table is given:


PHP artisan make: migration create_blogs_table --create=blogs
//PHP artisan make:migration add_votes_to_blogs_table --table=blogs

When performing the make: transfer request, you can use the —path option if you want to specify a customized destination path for the created integration. The given pathway should be proportional to the base path of your submission.

Migration Structure

A migration class includes two techniques: upwards and downwards. The up method can be used to add additional tables, columns, or directories to the database, whereas the down method will reverse the up method operations.
In any of those methods, you can elegantly create and change tables using the Laravel Schema Builder. Look out the information to learn about all the options available on the Schema creator. For example, this example of migration produces a table of flights:

<?php
use Illuminate\Support\Facades\Schema; 
use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 
 
class CreateBlogsTable extends Migration 
{ 
    /**
     * Run the migrations.
     *
     * @return void
     */ 
    public function up() 
    { 
            Schema::create('blogs', function (Blueprint $table) { 
            $table->bigIncrements('id'); 
            $table->string('title'); 
            $table->string('desciption'); 
            $table->rememberToken(); 
            $table->timestamps(); 
        }); 
    } 
 
    /**
     * Reverse the migrations.
     *
     * @return void
     */ 
    public function down() 
    { 
        Schema::dropIfExists('blogs'); 
    } 
}
?>

Running Migrations

so now if you want to run all of your outstanding migrations, execute the migrate Artisan command:

PHP artisan migrate

When you use the windows system from Farmstead, you can run the control from inside your windows machine.

Forcing Migrations To Run in Production

Some transformation operations are harmful, meaning that they can cause data loss. To stop you from operating these instructions against your development database, you'll be prompted for confirmation before executing the commands. To compel commands to run with no request, use the flag —control:

PHP artisan migrate --force

Read More...
Also, Visit Here  PHP Tutorial

Comments

Popular posts from this blog

Python Tutorial for Beginners

Learn Python with Industrial Experts with Examples Python is a popular general-purpose high-level, interactive and object-oriented scripting language that was invented by Guido Rossum in 1990. Python programming is commonly used in Computing Science in Artificial Intelligence, Human language Generation, Neural Networks and other specialized fields. Python for beginners , it has a basic syntax that is easy to use. That makes Python an outstanding language for novice to learn technology. Why Learn Python It is the most common and rapidly growing programming language of the present time. Here are 10 explanations for learning Python:   1.  It is simple and easy to understand  2.  It is very popular and on-demand  3   It has several libraries and frameworks  4.  It is often used in Data science  5.  It is often used in Artificial Intelligence and Machine Learning  6....

Best Way To Learn SEO

Learn SEO Before learning the subject, let’s understand something about it. Search engine optimization (SEO) is basically a process of improving the positions in the organic (non-paid) search results in the search engines. Please note that the higher the website is, the more people will be able to see it. The history of the SEO go back to the 90s when there were search engines emerged as for the first time. Nowadays, it is an essential marketing strategy and also an ever-growing industry.  Even the basic can change can usually make a very big difference in the terms that how search engines will see your website. In order to learn SEO , one should learn the basics of it from an SEO guide for beginners that is available on the web generally with all the points that cover all the critical topics and the basics.   The good thing about learning is that you’ll find basically tons of the information on the internet for free but the user should be able to ...

Download Free PHP Projects

PHP is a language used in the server scripting process. It is not used in static websites but if you want an interactive web page then PHP is the best way to write the code. The software is completely open-source and you can download it for free. You can also opt for some free PHP projects to understand the whole language properly. If you search online, you will find a lot of PHP projects available for download. You can get them and start practicing.   Administrative Panel with Login and Registration Facility   If you are searching for PHP free projects online then this project can be of great help to you. Here you have to make a full-fledged administrative panel with the feature of user login and user registration process. So, you will get to learn how to make a user management portal by using PHP software. You can get the project requirement and source code online.   Student Record Management   It is another unique project for your PHP practice. ...