<legend id='0mjFN'><style id='0mjFN'><dir id='0mjFN'><q id='0mjFN'></q></dir></style></legend>
  • <i id='0mjFN'><tr id='0mjFN'><dt id='0mjFN'><q id='0mjFN'><span id='0mjFN'><b id='0mjFN'><form id='0mjFN'><ins id='0mjFN'></ins><ul id='0mjFN'></ul><sub id='0mjFN'></sub></form><legend id='0mjFN'></legend><bdo id='0mjFN'><pre id='0mjFN'><center id='0mjFN'></center></pre></bdo></b><th id='0mjFN'></th></span></q></dt></tr></i><div id='0mjFN'><tfoot id='0mjFN'></tfoot><dl id='0mjFN'><fieldset id='0mjFN'></fieldset></dl></div>

      <small id='0mjFN'></small><noframes id='0mjFN'>

    1. <tfoot id='0mjFN'></tfoot>
        <bdo id='0mjFN'></bdo><ul id='0mjFN'></ul>

        未定义的表:7 错误:关系“费用";不存在

        时间:2023-09-22
        • <small id='3EV4t'></small><noframes id='3EV4t'>

            <tbody id='3EV4t'></tbody>
            <bdo id='3EV4t'></bdo><ul id='3EV4t'></ul>
            <tfoot id='3EV4t'></tfoot>
                <legend id='3EV4t'><style id='3EV4t'><dir id='3EV4t'><q id='3EV4t'></q></dir></style></legend>
                <i id='3EV4t'><tr id='3EV4t'><dt id='3EV4t'><q id='3EV4t'><span id='3EV4t'><b id='3EV4t'><form id='3EV4t'><ins id='3EV4t'></ins><ul id='3EV4t'></ul><sub id='3EV4t'></sub></form><legend id='3EV4t'></legend><bdo id='3EV4t'><pre id='3EV4t'><center id='3EV4t'></center></pre></bdo></b><th id='3EV4t'></th></span></q></dt></tr></i><div id='3EV4t'><tfoot id='3EV4t'></tfoot><dl id='3EV4t'><fieldset id='3EV4t'></fieldset></dl></div>

                  本文介绍了未定义的表:7 错误:关系“费用";不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  因为我会说西班牙语,所以我用西班牙语写了收入和支出的控制器和模型;而其余的都是英文的..我手动重命名和更改了路由、控制器、迁移甚至模型.当我运行 php artisan migrate:reset 这是我的错误.

                  Since i am a spanish speaker, i wrote the controllers and models of income and expense in spanish; while all the rest were on english.. I renamed and changed manually Routes, Controllers, Migrations and even Models. And when i run php artisan migrate:reset this is my error.

                  未定义表:7 错误:关系费用"不存在(SQL:更改表费用"删除列location_id")**

                  Undefined table: 7 ERROR: relation "expenses" does not exist (SQL: alter table "expenses" drop column "location_id")**

                  我使用 psgql 和 laravel 5.3

                  I use psgql and laravel 5.3

                  这是我的代码:

                      <?php
                  
                      namespace App;
                  
                      use IlluminateDatabaseEloquentModel;
                  
                      class Expense extends Model
                      {
                  
                          protected $fillable = ['id', 'description', 'quantity'];
                  
                  
                          public function locations()
                          {
                  
                              return $this->hasMany('AppLocation');
                  
                          }
                          public function icons()
                          {
                  
                              return $this->hasMany('AppIcon');
                          }
                          public function types()
                          {
                  
                              return $this->hasMany('AppType');
                          }
                          public function stores()
                          {
                  
                              return $this->hasMany('AppStore');
                          }
                  
                      }
                  

                  迁移:

                      <?php
                  
                  use IlluminateSupportFacadesSchema;
                  use IlluminateDatabaseSchemaBlueprint;
                  use IlluminateDatabaseMigrationsMigration;
                  
                  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');
                      }
                  }
                  

                  位置迁移:

                  <?php
                  
                  use IlluminateSupportFacadesSchema;
                  use IlluminateDatabaseSchemaBlueprint;
                  use IlluminateDatabaseMigrationsMigration;
                  
                  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');
                      }
                  }
                  

                  型号:

                  <?php
                  
                  namespace App;
                  
                  use IlluminateDatabaseEloquentModel;
                  
                  class Location extends Model
                  {
                  
                      protected $fillable = ['id', 'address', 'lat', 'long'];
                  
                  
                      public function expenses()
                      {
                  
                          return $this->belongsTo('AppExpense');
                      }
                  
                      public function stores()
                      {
                  
                          return $this->hasOne('AppStore');
                      }
                  }
                  

                  希望你能帮助我.

                  推荐答案

                  当它说

                  relation "expenses" does not exist
                  

                  通常发生在您的费用表必须在 migration:reset 回滚 CreateLocationsTable 之前被删除时.

                  It usually happens when your expenses table must have been dropped before migration:reset rolled back CreateLocationsTable.

                  检查迁移的执行顺序.

                  当您尝试重置时,现在要修复它,请打开您的数据库,手动删除所有表并再次执行 migrate.

                  As you were trying to reset, to fix it now, open your database, drop all tables manually and execute migrate again.

                  这篇关于未定义的表:7 错误:关系“费用";不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:json 资源和 json 资源有什么区别?资源收集?在 La 下一篇:自动注入的 Laravel 模型没有属性

                  相关文章

                  最新文章

                  <tfoot id='cXPbp'></tfoot>
                1. <i id='cXPbp'><tr id='cXPbp'><dt id='cXPbp'><q id='cXPbp'><span id='cXPbp'><b id='cXPbp'><form id='cXPbp'><ins id='cXPbp'></ins><ul id='cXPbp'></ul><sub id='cXPbp'></sub></form><legend id='cXPbp'></legend><bdo id='cXPbp'><pre id='cXPbp'><center id='cXPbp'></center></pre></bdo></b><th id='cXPbp'></th></span></q></dt></tr></i><div id='cXPbp'><tfoot id='cXPbp'></tfoot><dl id='cXPbp'><fieldset id='cXPbp'></fieldset></dl></div>

                    <small id='cXPbp'></small><noframes id='cXPbp'>

                      <bdo id='cXPbp'></bdo><ul id='cXPbp'></ul>

                  1. <legend id='cXPbp'><style id='cXPbp'><dir id='cXPbp'><q id='cXPbp'></q></dir></style></legend>