Laravel 5 Tutorial : Database Migration & Schema in Laravel 5.3

Laravel 5 Tutorial for beginners : how to user make:migration and make:rollback in laravel Database Migration & Schema in Laravel 5.3?

Laravel 5 Tutorials - How to Generating database migrations in laravel 5.3? make:migration command in Laravel 5.3 will help us to create database tables using Artisan CLI. All migration file as we have created before will saved in database\migrations folder.

Please read :
  1. How to Connect Database in laravel 5.3
  2. Routing Basics in Laravel
Migration mean a facility in laravel used to change or make any tables or columns in the database. The schema Builder is used to create a database schema. With migrations and schema builder will be easier when we make great project and with a different developer to be the developer of this does not need to import/export the database but just use migration.

To use the migration, you must have connected to your database before.

Database Migration & Schema in Laravel 5.3

Generating Migrations

Follow this artisan command to make new migration :

php artisan make:migration create_users_table

You can create migration using more options like using The --table and --create Options to artisan command :

php artisan make:migration create_users_table --create=users

php artisan make:migration add_votes_to_users_table --table=users

All migration file as we have created before will saved in database\migrations folder.

After success create migration file, at default migration file in database\migrations folder, look this migrations schema file.

Migration Structure

<?php

use IlluminateSupportFacadesSchema;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;

class CreateBiodataTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('biodata', function (Blueprint $table) {
            $table->increments('id');
            $table->string('titles');
            $table->string('descriptions');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('biodata');
    }
}

Running Migrations

You can create all your tables in the function up(), you know, function up() will create any table or column to our database, and the function down() is to drop or delete any table and column from our database.

Just configuration and then execute this artisan command to create our table :

php artisan migrate

Rolling Back Migrations

migrate:rollback command use to drop our table, see example below

php artisan migrate:rollback

Video Tutorial Database Migration & Schema in Laravel 5.3


See you next Lessons..............

COMMENTS

Next Recomended


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: Laravel 5 Tutorial : Database Migration & Schema in Laravel 5.3
Laravel 5 Tutorial : Database Migration & Schema in Laravel 5.3
Laravel 5 Tutorial for beginners : how to user make:migration and make:rollback in laravel Database Migration & Schema in Laravel 5.3?
https://4.bp.blogspot.com/-P_jDDETdxxE/V8Mon4qRCRI/AAAAAAAACWI/nd5et4n0pHA71v7fjnD8Ugl2Ii8wdovXQCLcB/s320/laravel-tutorial-for-beginner.png
https://4.bp.blogspot.com/-P_jDDETdxxE/V8Mon4qRCRI/AAAAAAAACWI/nd5et4n0pHA71v7fjnD8Ugl2Ii8wdovXQCLcB/s72-c/laravel-tutorial-for-beginner.png
KODE AJAIB
https://www.kodeajaib.com/2016/08/laravel-5-tutorial-database-migration.html
https://www.kodeajaib.com/
https://www.kodeajaib.com/
https://www.kodeajaib.com/2016/08/laravel-5-tutorial-database-migration.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy