Monday, 11 January 2021

Check if Table/Column Already Exists

Check if Table/Column Already Exists


public function up()
{
  if (!Schema::hasTable('vendor')) {
    Schema::create('vendor', function (Blueprint $table) {
      $table->increments('id');
      $table->string('name');      
      $table->timestamps();
    });
  }
}

public function up()
{
  if (Schema::hasTable('vendor')) {
    Schema::table('vendor', function (Blueprint $table) {
      if (!Schema::hasColumn('vendor', 'address')) {
        $table->string('address');
      }
    });
  }
}

No comments:

Post a Comment

Machine Learning - Potato Leaf Disease Prediction

Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...