PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 11, 2022

[FIXED] How to drop table in Laravel?

 March 11, 2022     laravel-5     No comments   

Issue

The problem is that I have this error:

[PDOException]

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'songs' already exists

This is my migration file:

<?php 
use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 
class CreateSongsTable extends Migration 
{
    public function up() 
    {
        Schema::create('songs', function (Blueprint $table) 
        {
            $table->increments('id');
            $table->integer('user_id');
            $table->string('title');
            $table->string('slug')->unique();
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }
}

I think the solution will be just to delete the table then run migration again, so how can I drop a table in Laravel 5 using the command line? I am using MySQL.


Solution

A nice easy way that I found is just using phpmyadmin and just drop the table manually. Of course if the migration is still there when you run the migration again the table will be created again.



Answered By - koooko
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing