代码之家  ›  专栏  ›  技术社区  ›  Sagar Gautam

供应商发布后,不会使用artisan命令从包中执行新创建的迁移

  •  0
  • Sagar Gautam  · 技术社区  · 8 年前

    我刚开始在拉威尔创建软件包。我做了一个调查包,包内我做了以下目录结构。

    Screenshot

    现在,我从服务提供商那里加载了如下文件:,

    调查服务提供商。php

    <?php
    
    namespace Survey;
    use Illuminate\Support\ServiceProvider;
    use Illuminate\Support\Facades\Schema;
    
    class SurveyServiceProvider extends ServiceProvider
    {
    public function boot()
    {
        Schema::defaultStringLength(191);
        
        $this->loadRoutesFrom(__DIR__.'/routes/web.php');
        $this->loadMigrationsFrom(__DIR__.'/./../publishables/database/migrations');
        $this->loadViewsFrom(__DIR__.'/./../resources/views/','survey');
    }
    
    public function register()
    {
        $this->registerPublishables();
    }
    
    private function registerPublishables()
    {
        $basePath = dirname(__DIR__);
    
        $arrPublishable = [
            'migrations' => [
                "$basePath/publishables/database/migrations" => database_path('migrations'),
                "$basePath/publishables/config/survey.php" => config_path('survey.php'),
          ]
        ];
    
        foreach ($arrPublishable as $group => $paths) {
            $this->publishes($paths,$group);
        }
    }
    }
    

    我的迁移文件是在 vendor:publish 命令

    <?php
    
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;
    
    class CreateAuditsTable extends Migration
    {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('audits', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->boolean('is_published');
            $table->timestamps();
        });
    }
    
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('audits');
    }
    } 
    

    但是,当我执行 php artisan migrate 审计迁移文件没有执行任何原因在那里。

    还有一件事,我已经执行了 composer dumpautoload 命令

    请询问是否需要进一步的细节。

    0 回复  |  直到 6 年前
    推荐文章