rinvex / laravel-attributes

⚠️ [ABANDONED] Rinvex Attributable is a robust, intelligent, and integrated Entity-Attribute-Value model (EAV) implementation for Laravel Eloquent, with powerful underlying for managing entity attributes implicitly as relations with ease. It utilizes the power of Laravel Eloquent, with smooth and seamless integration.
MIT License
433 stars 104 forks source link

ERROR: column "id" does not exist #146

Closed alexfarrugia closed 2 years ago

alexfarrugia commented 3 years ago

Hi, I'm using Laravel-attributes version 4 and when i try to add a new attribute using the below code: app('rinvex.attributes.attribute')->create([ 'slug' => 'unbilledMinutes', 'type' => 'integer', 'name' => 'Unbilled Minutes', 'entities' => ['App\Client'], ]);

I am being given the following error:

Illuminate\Database\QueryException

SQLSTATE[42703]: Undefined column: 7 ERROR: column "id" does not exist LINE 1: ...ed_at", "created_at") values ($1, $2, $3, $4) returning "id" ^ (SQL: insert into "attribute_entity" ("entity_type", "attribute_id", "updated_at", "created_at") values (App\Client, 3, 2021-01-21 15:00:42, 2021-01-21 15:00:42) returning "id")

at C:\Codex\timesheets_laravel\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667▕ // If an exception occurs when attempting to run a query, we'll format the error 668▕ // message to include the bindings with SQL, which will make this exception a 669▕ // lot more helpful to the developer instead of just the database's errors. 670▕ catch (Exception $e) { ➜ 671▕ throw new QueryException( 672▕ $query, $this->prepareBindings($bindings), $e 673▕ ); 674▕ } 675▕

1 .....\vendor\laravel\framework\src\Illuminate\Database\Connection.php:336 PDOException::("SQLSTATE[42703]: Undefined column: 7 ERROR: column "id" does not exist LINE 1: ...ed_at", "created_at") values ($1, $2, $3, $4) returning "id" ^")

2 ....\vendor\laravel\framework\src\Illuminate\Database\Connection.php:336 PDOStatement::execute()

Has anyone enocuntered this before?

Something worth mentioning is that I am using PostgreSQL and that all my Models use UUID columns, as a matter of fact i have changed the migration scripts to change all columns referring to entities from int columns to uuid columns.

thanks for your help

Alex

tungtreviet commented 3 years ago

Create a new migration, and add this

<?php

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

class Eav extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table(config('rinvex.attributes.tables.attribute_entity'), function (Blueprint $table) {
            $table->id();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::create(config('rinvex.attributes.tables.attribute_entity'), function (Blueprint $table) {
            $table->dropColumn('id');
        });
    }
}
Omranic commented 2 years ago

This package wasn't tested with UUID, but I'd be happy to consider PRs that supports it, with no backward compatibility breaks.