0
votes

I cannot migrate and make a new table field in phpmyadmin in my database it is giving me this error why?

my Modal name Setting

here is my modal as you can see I can't insert anything still coz I don't have my table in phpmyadmin.

    <?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Setting extends Model
{
    //
}

my Migration

here is my migration

 public function up()
{
    Schema::create('settings', function (Blueprint $table) {
        $table->increments('id');
        $table->string('settings_code');
        $table->string('subject');
        $table->text('description');
        $table->timestamps();
    });
}

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

Illuminate\Database\QueryException : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'clients' already exists (SQL: create table clients (id int unsigned not null auto_increment primary key, client_code varchar(191) not null, client_name varchar(191) not null, address varchar(191) not null, tel_no varchar(191) not null, contact_person varchar(191) not null, mobile_no varchar(191) not null, email_ad varchar(191) not null, website varchar(191) not null, deleted_at timestamp null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

I want to create a new table not client table but it is giving me this error. why?

2
use php artisan migrate:fresh it's will dropped all table and migrate new onesMD. Jubair Mizan
Message is quite clear, table already exists. How are you calling your migrations? Can you edit your question and paste your migration? Wait "I cannot create a new table field in phpmyadmin" You're not using migrations but phpmyadmin?brombeer
Can you provide your code?cham
There it is sorry im just in a hurryuser10665294
laravel.com/docs/5.7/migrations php artisan migrate:fresh drops all existing tables (and thus data) and runs your migrations from the start. So no "duplicate" tables. @MD.JubairMizan commented "the solution" first, so he should get props for an answerbrombeer

2 Answers

3
votes

Run:php artisan migrate:fresh

Be warned This will remove anything stored within the database so ensure you have a Seeder setup to place any relevant content back into the database.

In the event you get an Specified key was too long error on the re migrate open AppServiceProvider and add:

Schema::defaultStringLength(191); into the boot function

Ensure you add use Illuminate\Support\Facades\Schema; at the top of the AppServiceProvider file

0
votes

hi try to romove your database from phpmyadmin and create again then run php artisan migrate to login go to your table user and create a user manually in BD and in your model put fillable with your data stored