sunel / eav

Entity–attribute–value model (EAV) for Laravel Artisan
https://sunel.github.io/eav/
143 stars 39 forks source link

Invalid default value for 'created_at' #11

Closed sinamiandashti closed 6 years ago

sinamiandashti commented 6 years ago

hello

when i try to compile flat table using this command : php artisan eav:compile:entity product

Following error happens :

Compiling product entity. Creating flat table for products. Found 8 attributes. Migrating products flat schema.

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' (SQL: create table products_flat (id int unsigned not null, entity_id int unsigned not null, attribute_set_id int unsigned not null, slug varchar(255) not null, order varchar(255) not null, visit_count int not null auto_increment primary key, created_at timestamp null default 'NULL', updated_at timestamp null default 'NULL', deleted_at timestamp null default 'NULL', sku varchar(255) null, name varchar(255) null, name_en varchar(255) null, search varchar(255) null, description varchar(255) null, status varchar(255) null, is_active varchar(255) null, brand varchar(255) null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

sinamiandashti commented 6 years ago

fixed in https://github.com/sunel/eav/pull/12

sunel commented 6 years ago

in your products table what is the default value for created_at & updated_at, is it set to NULL or ''

sinamiandashti commented 6 years ago
class CreateProductEntityMainTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('entity_id')->unsigned();
            $table->integer('attribute_set_id')->unsigned();

            $table->string('slug');
            $table->smallInteger('order');
            $table->integer('visit_count');
//                ->onDelete('set null');
            $table->timestamps();

            $table->softDeletes();

        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('products');       
    }
}
sunel commented 6 years ago

@sinamiandashti Thanks for the pull request, i am working on the test cases and few more changes are being added regarding the flat table.

sunel commented 6 years ago

@sinamiandashti

Need some suggestion,

What is preferred way to letting know that flat is being activated.

1) Value is in DB. 2) Through Configuration.

sinamiandashti commented 6 years ago

Through Configuration

sinamiandashti commented 6 years ago

can u please merge my request , we are heavily working with your package and need this fix

sunel commented 6 years ago

@sinamiandashti

Will merge for now, remember there is no tagged release.

NOTE: Changes are made rapidly in master branch, working on a stable relaease

sinamiandashti commented 6 years ago

thanks

sinamiandashti commented 6 years ago

should we git ignore this folder ? database/migrations/eav/ @sunel

sunel commented 6 years ago

Yes

sunel commented 6 years ago

@sinamiandashti

What version of mysql are you using.

sinamiandashti commented 6 years ago

Maria DB 10.2

sunel commented 6 years ago

https://sunel.github.io/eav/master/ideology/flat-table.html