【问题标题】:Laravel 5.5 migration errorLaravel 5.5 迁移错误
【发布时间】:2018-02-23 22:38:22
【问题描述】:

我正在尝试迁移我的 postgresql 表,但是当启动命令 php artisan migrate 时,它返回以下错误:

SQLSTATE[08P01]: : 7 错误:绑定消息提供 1 个参数,但准备好的语句“pdo_stmt_00000003”需要 2 个(SQL: select * from information_schema.tables 其中 table_schema = 迁移和 table_name = ?)

我的一个迁移:

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

class CreateSchedulesTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('schedules', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('schedule_name')->unique();
        $table->integer('parent_id')->unsigned()->nullable();
        $table->integer('launch_sequence_id')->unsigned();
        $table->string('day_of_week', 10)->nullable();
        $table->string('command_type', 50);
        $table->integer('hours')->unsigned()->nullable();
        $table->integer('minutes')->unsigned()->nullable();
        $table->integer('dd')->unsigned()->nullable();
        $table->integer('mm')->unsigned()->nullable();
        $table->integer('yyyy')->unsigned()->nullable();
        $table->boolean('enabled')->default(1);
        $table->boolean('ascending')->default(0);
        $table->dateTime('last_execution')->nullable();
        $table->dateTime('last_success')->nullable();
        $table->integer('retry')->default(0);

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

    DB::statement('ALTER TABLE schedules ADD CONSTRAINT day_of_week_check CHECK ((day_of_week)::text = ANY (ARRAY[(\'all\'::character varying)::text, (\'monday\'::character varying)::text, (\'tuesday\'::character varying)::text, (\'wednesday\'::character varying)::text, (\'thursday\'::character varying)::text, (\'friday\'::character varying)::text, (\'saturday\'::character varying)::text, (\'sunday\'::character varying)::text]))');
}


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

}

还有我的数据库配置:

'default' => env('DB_CONNECTION', 'pgsql'),
'connections' => [

    'pgsql' => [
        'driver' => 'pgsql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'schema' =>  env('DB_SCHEMA', 'public'),
        //'sslmode' => 'prefer',
    ]
],

我的 .env

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=livion
DB_USERNAME=livion
DB_PASSWORD=secret
DB_SCHEMA=public

我试图追踪它,似乎它没有为函数 repositoryExists 使用正确的语法,它使用了默认语法,女巫不发送架构参数。

通过模型或存储库执行的其他查询工作正常,我仅在迁移命令时收到此错误。

有解决这个问题的建议吗?

【问题讨论】:

  • 也发布您的迁移代码
  • 您是否在配置文件/dotenv 文件中检查过您的数据库驱动程序?像 DB_CONNECTION=postgresql
  • 我用我的配置编辑我的帖子
  • 你运行的是什么版本的php?
  • 我在 Ubuntu 17.10 上使用 PHP 7.1.11

标签: php laravel migration


【解决方案1】:

我找出问题所在。 我将项目从 laravel 5.3 迁移到 5.5,旧项目使用模块 Aejnsn\Postgresify。

这会导致我在迁移时遇到问题。

删除它,一切都会重新开始。

【讨论】:

    猜你喜欢
    • 2018-07-06
    • 2019-02-07
    • 2018-10-18
    • 2018-04-26
    • 2018-06-18
    • 2018-06-05
    • 2018-04-24
    相关资源
    最近更新 更多