lundi 31 octobre 2016

Error on migration:rollback that should drop a column- Using Laravel Homestead & SQlite

I'm getting an error on running "php artisan migrate:rollback" that should drop a column.

I've already ran:
1. composer require doctrine/dbal
2. composer update
3. I even tried "composer dump-autoload"

When I check on the database schema using: "sqlite3 database/database.sqlite" the table contains all the columns (including the one called "excerpt" which is the rogue one that should be dropped) but on running the rollback I get the error that the column isn't published. See below.

(Environment: laravel 5.3- Homestead, Gitbash, Sublime Text3, SQlite3)

The error is as follows:

[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1 no such column: published (SQL: CREATE TEMPORARY TABLE __temp__articles AS SELECT id, title, body, created_at, updated_at, published at FROM articles)

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000]: General error: 1 no such column: published

[PDOException]
SQLSTATE[HY000]: General error: 1 no such column: published

My schema is as follows:

CREATE TABLE "migrations" ("id" integer not null primary key autoincrement, "migration" varchar not null, "batch" integer not null);
CREATE TABLE "users" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar null, "created_at" datetime null, "updated_at" datetime null);
CREATE UNIQUE INDEX "users_email_unique" on "users" ("email");
CREATE TABLE "password_resets" ("email" varchar not null, "token" varchar not null, "created_at" datetime null);
CREATE INDEX "password_resets_email_index" on "password_resets" ("email");
CREATE INDEX "password_resets_token_index" on "password_resets" ("token");
CREATE TABLE "articles" ("id" integer not null primary key autoincrement, "title" varchar not null, "body" text not null, "created_at" datetime null, "updated_at" datetime null, "published at" datetime not null, "excerpt" text null);

The Migration that created the column is as follows:

<?php

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

class AddExcerptToArticlesTable extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('articles', function (Blueprint $table) {

        $table->text("excerpt")->nullable();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('articles', function (Blueprint $table) {

        $table->dropColumn("excerpt");

    });
}
}

How do you solve this so that you can seamlessly drop columns using migrate:rollback?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2f5jJf8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire