TECHNICALSTUDY

The associate of technical study article for computer science students which could gain the knowledge about to technicals like Computer history, hard disk, printer,central processing unit etc. Technicalstudy also considered software engineering, operating system and some chunks of programming languages.

Email subscription

Enter your email address:

Delivered by FeedBurner

Thursday, October 12, 2023

ALL New Column in Existing Table

 

Make Migration  - php artisan make:migration new_column_name --table=existing_table_name

Do Change Migration File like following : 


<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
       

        Schema::table('users', function (Blueprint $table) {

            $table->after('password', function (Blueprint $table) {
            $table->integer('created_id')->nullable();
             
            });
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('created_id');
        });
    }
};

 
After That Migrate Specific Migration File


php artisan migrate:refresh --path=database/migrations/2023_10_12_160607_created_id.php


No comments:

Post a Comment

Adbox