Skip to content

Instantly share code, notes, and snippets.

@3h5a9
Last active September 9, 2017 07:34
Show Gist options
  • Select an option

  • Save 3h5a9/5fc1aaacb54b952f9ac64d6ee4a3cfe0 to your computer and use it in GitHub Desktop.

Select an option

Save 3h5a9/5fc1aaacb54b952f9ac64d6ee4a3cfe0 to your computer and use it in GitHub Desktop.
migrate:refresh showing error
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateStudentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->increments('id');
$table->string('fname');
$table->string('mname');
$table->string('lname');
$table->string('dob');
$table->string('gender');
$table->string('bloodgroup');
$table->string('bplace');
$table->string('nationality');
$table->string('religion');
$table->mediumText('presentadd');
$table->mediumText('permanentadd');
$table->string('city');
$table->string('ps');
$table->string('zipcode');
$table->string('phone');
$table->string('mobile');
$table->string('email')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('students');
}
}
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddRcsToStudentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('students', function ($table) {
$table->string('roll')->unique()->after('email');
$table->string('class')->after('roll');
$table->string('section')->after('class');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function ($table) {
$table->dropColumn('roll');
$table->dropColumn('class');
$table->dropColumn('section');
});
}
}
The Following errors are showing after php artisan:reset or php artisan:refresh or php artisan:rollback command
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'roll'; check that column/key exists (SQL: alter table `users` drop `roll`)
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'roll'; check that column/key exists
@3h5a9
Copy link
Copy Markdown
Author

3h5a9 commented Sep 9, 2017

Error is Schema::table('students', function ($table)


Schema::table('users', function ($table) { $table->string('roll')->unique()->after('email'); $table->string('class')->after('roll'); $table->string('section')->after('class'); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment