Базовая таблица или представление не найдены Таблица «tenancy.websites» не найдена

После того, как я установил мультитенантный пакет hyn и запустил php artisan tenancy:migrate, я получил сообщение об ошибке «базовая таблица не найдена». Предполагается, что команда перенесет три миграции. Первый из них 2017_01_01_000003_tenancy_websites.php. Вот содержание...

<?php

class TenancyWebsites extends AbstractMigration
{
    protected $system = true;

    public function up()
    {
        Schema::create('websites', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->string('uuid');

            $table->timestamps();
            $table->softDeletes();
        });
    }

    public function down()
    {
        Schema::dropIfExists('websites');
    }
}

Затем 2017_01_01_000005_tenancy_hostnames.php. Вот содержание...

<?php

class TenancyHostnames extends AbstractMigration
{
    protected $system = true;

    public function up()
    {
        Schema::create('hostnames', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->string('fqdn')->unique();
            $table->string('redirect_to')->nullable();
            $table->boolean('force_https')->default(false);
            $table->timestamp('under_maintenance_since')->nullable();
            $table->bigInteger('website_id')->unsigned()->nullable();

            $table->timestamps();
            $table->softDeletes();

            $table->foreign('website_id')->references('id')->on('websites')->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::dropIfExists('hostnames');
    }
}

Затем 2017_01_01_000003_tenancy_hostnames.php. Вот содержание...

class TenancyWebsitesNeedsDbHost extends AbstractMigration
{
    protected $system = true;

    public function up()
    {
        Schema::table('websites', function (Blueprint $table) {
            $table->string('managed_by_database_connection')
                ->nullable()
                ->comment('References the database connection key in your database.php');
        });
    }

    public function down()
    {
        Schema::table('websites', function (Blueprint $table) {
            $table->dropColumn('managed_by_database_connection');
        });
    }
}

Я выполнил все шаги в их документации. Что не так с кодом?


person Patrick Obafemi    schedule 31.10.2018    source источник
comment
Откуда ты взял php artisan tenancy:migrate? В ридми об этом не упоминается.   -  person Devon    schedule 31.10.2018
comment
можешь показать таблицу миграции базы данных   -  person Shaielndra Gupta    schedule 31.10.2018
comment
@Девон из документации   -  person Patrick Obafemi    schedule 01.11.2018


Ответы (1)


Ничего в коде... это имена файлов, которые не отсортированы правильно. порядок выполнения зависит от имени файла это ваш заказ

  1. 2017_01_01_000003_tenancy_hostnames.php
  2. 2017_01_01_000003_tenancy_websites.php
  3. 2017_01_01_000005_tenancy_hostnames.php

правильный порядок должен быть (назван с тем же именем класса)

  1. 2017_01_01_000003_TenancyWebsites.php
  2. 2017_01_01_000005_TenancyHostnames.php
  3. 2017_01_01_000007_TenancyWebsitesNeedsDbHost.php
person simonecosci    schedule 31.10.2018
comment
я переставил их, как вы сказали, и я все еще получаю ту же ошибку. - person Patrick Obafemi; 31.10.2018