【问题标题】:Laravel migrate not create table in postgresql databaseLaravel 迁移不在 postgresql 数据库中创建表
【发布时间】:2017-02-08 15:51:52
【问题描述】:

我是 Laravel 的初学者。我想问一下为什么 Laravel migrate 不在我的数据库中创建我的表?这是我的 .env 文件:

APP_ENV=local
APP_KEY=base64:9FLWfylvrtxjXdunJujBDq37Q4QtKcoiPdmeJbgbLSg=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=laravel5
DB_USERNAME=postgres
DB_PASSWORD=1111

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

这是我的迁移文件:

<?php

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

class CreateMySongsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('songs', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('artist');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('songs');
    }
}

首先 1.运行php artisan migrate 迁移:2017_02_08_130207_create_articles_table

然后在 postgresql 中运行 新足球=# \dt 未找到任何关系。

请有人帮助我。谢谢你的耐心。

【问题讨论】:

    标签: migration laravel-5.4


    【解决方案1】:

    我终于找到了解决方案。由于 .env 文件的更改需要运行以下命令。

    php artisan config:cache
    

    然后一切正常。谢谢你。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-10
      • 1970-01-01
      • 2016-02-28
      • 2014-05-03
      • 2015-03-28
      • 2021-06-19
      • 2021-01-17
      相关资源
      最近更新 更多