【问题标题】:Database error when I uploaded my laravel project on AWS which was working fine in development当我在 AWS 上上传我的 laravel 项目时出现数据库错误,该项目在开发中运行良好
【发布时间】:2021-03-12 03:58:45
【问题描述】:

我只是一个初学者,所以这个问题可能很愚蠢。 我在开发时使用 sqlite,当我在 AWS 上上传我的项目时,我收到了这个错误:-

SQLSTATE[HY000]: 一般错误: 1366 不正确的整数值: 'f2bbac78-d85f-42fd-ba4c-276c2d9ee2b6' 列 'confessedTo' 在第 1 行 (SQL: 插入到confessions (confession, @987654323 @, confessionFrom, updated_at, created_at) 值 (AFCASCASCa, f2bbac78-d85f-42fd-ba4c-276c2d9ee2b6, 1, 2020-11-30 08:02:09, 2020-11-30 08:02: 09))

这是那张桌子:-

public function up()
    {
        Schema::create('confessions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('confessedTo');
            $table->unsignedBigInteger('confessionFrom');
            $table->text('confession');
            $table->string('name')->nullable();

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

是因为我在我的confessedTo 列中传递了uuid 这是f2bbac78-d85f-42fd-ba4c-276c2d9ee2b6 这种类型的数据吗?
请帮忙

修改 我已将所有表格中的属性更改为uuid,但其中一个表格似乎无法正常工作,如下所列:-

之前:-

public function up()
    {
        Schema::create('messages', function (Blueprint $table) {
            $table->id();
            $table->integer('from')->unsigned();
            $table->integer('to')->unsigned();
            $table->text('text');   
            $table->string('list_no')->nullable(); 
            $table->timestamps();
        });
    }

之后:-

public function up()
    {
        Schema::create('messages', function (Blueprint $table) {
            $table->id();
            $table->uuid('from');
            $table->uuid('to');
            $table->text('text');   
            $table->string('list_no')->nullable(); 
            $table->timestamps();
        });
    }

这是我未读邮件的来源:-

public function up()
    {
        Schema::table('messages', function (Blueprint $table) {
            $table->boolean('read')->after('to')->default(false);
        });
    }

错误:-

SQLSTATE[42S22]:找不到列:1054 未知列“读取”在“where 子句”中(SQL:选择 from 作为 sender_id,计数(from)作为来自 messages 的 messages_count,其中 to = f2bbac78-d85f-42fd-ba4c-276c2d9ee2b6 和 read = 0 分组 from)

请帮忙..

【问题讨论】:

  • 是的。 confessedTocolum 只接受整数。但是您正在传递一个带有混合字符的字符串。所以将该列设为 uuid

标签: mysql laravel amazon-web-services sqlite


【解决方案1】:

是的。您应该将confessedTo 列类型更改为uuid 或使用整数值而不是uuid

$table->uuid('confessedTo');

参考:Laravel Documentation

【讨论】:

  • 我确实在我的所有表格中将其更改为 uuid,但它在我的一张表格中不起作用,我在我的问题中对其进行了更新,请帮助
  • 您是否在更改迁移文件后刷新了迁移?
猜你喜欢
  • 1970-01-01
  • 2021-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-13
  • 2019-02-04
  • 2022-11-25
相关资源
最近更新 更多