Undefined table: 7 FEHLER: relation "Aufwand" nicht vorhanden
Da bin ich ein Spanisch-Lautsprecher, die ich schrieb, den Controllern und models Einnahmen und Ausgaben in Spanisch, während alle anderen waren auf Englisch..
Ich umbenannt und manuell geändert Routen, Controller, Migration und sogar Modelle.
Und wenn ich mit php artisan migrate:reset das ist mein Fehler.
Undefined table: 7 FEHLER: relation "Aufwand" ist nicht vorhanden (SQL: alter table "Aufwendungen" drop column "location_id")**
Benutze ich psgql und laravel 5.3
Das ist mein code:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Expense extends Model
{
protected $fillable = ['id', 'description', 'quantity'];
public function locations()
{
return $this->hasMany('App\Location');
}
public function icons()
{
return $this->hasMany('App\Icon');
}
public function types()
{
return $this->hasMany('App\Type');
}
public function stores()
{
return $this->hasMany('App\Store');
}
}
Migration:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateExpensesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('expenses', function (Blueprint $table) {
$table->increments('id');
$table->float('quantity');
$table->string('description');
$table->integer('location_id')->unsigned();
$table->integer('icon_id')->unsigned();
$table->integer('type_id')->unsigned();
$table->integer('store_id')->unsigned();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('expenses');
}
}
Standort-Migration:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLocationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('locations', function (Blueprint $table) {
$table->increments('id');
$table->string('address');
$table->float('lat');
$table->float('long');
$table->integer('store_id')->unsigned();
$table->timestamps();
$table->foreign('store_id')->references('id')->on('stores')->onDelete('cascade');
});
Schema::table('expenses', function (Blueprint $table) {
$table->foreign('location_id')->references('id')->on('locations')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('expenses', function (Blueprint $table) {
$table->dropColumn('location_id');
});
Schema::dropIfExists('locations');
}
}
Modell:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
protected $fillable = ['id', 'address', 'lat', 'long'];
public function expenses()
{
return $this->belongsTo('App\Expense');
}
public function stores()
{
return $this->hasOne('App\Store');
}
}
Hoffe Ihr könnt mir helfen.
Was ist es, das Sie nicht verstehen?
Ich bekomme diese Fehlermeldung, wenn ich versuche zu migrieren, um psgql.
Die Fehlermeldung ist ganz klar - Sie haben keine Tabelle mit dem Namen Kosten.
Ich habe tatsächlich migriert beiden Tabellen, aber wenn ich migrieren:status ich habe ein : N auf Sie, während die anderen Tabellen sind auf Y.
Ich bekomme diese Fehlermeldung, wenn ich versuche zu migrieren, um psgql.
Die Fehlermeldung ist ganz klar - Sie haben keine Tabelle mit dem Namen Kosten.
Ich habe tatsächlich migriert beiden Tabellen, aber wenn ich migrieren:status ich habe ein : N auf Sie, während die anderen Tabellen sind auf Y.
InformationsquelleAutor Julian Moreira | 2016-11-30
Du musst angemeldet sein, um einen Kommentar abzugeben.
Wenn er sagt,
Es in der Regel passiert, wenn Sie Ihre Ausgaben Tabelle muss gelöscht wurden, bevor
migration:reset
rollte zurückCreateLocationsTable
.Überprüfen Sie die Reihenfolge der Ausführung Ihrer Migrationen.
Als Sie versucht haben zurücksetzen, um es zu beheben, öffnen Sie Ihre Datenbank, löschen Sie alle Tabellen manuell und führen Sie
migrate
wieder.InformationsquelleAutor Antonio Carlos Ribeiro
ändern
InformationsquelleAutor Kiran Patel