php forge module:seed & php forge module:migrate



Installation 1 year ago by pesto9

Getting errors when running php forge module:seed & php forge module:migrate, any ideas here?

php forge module:seed: [Nova\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nova.nova_permissions'
doesn't exist (SQL: select * from nova_permissions where (slug = platform.ba
ckend.manage) limit 1)

php forge module:migrate: [Nova\Database\QueryException]
SQLSTATE[HY000]: General error: 1293 Incorrect table definition; there can be
only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE claus
e (SQL: create table nova_notifications (id int unsigned not null auto_inc
rement primary key, uuid varchar(40) not null, type varchar(255) not null,
notifiable_id int unsigned not null, notifiable_type varchar(255) not nul
l, data text not null, read_at timestamp null, created_at timestamp defa
ult CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTA
MP not null) default character set utf8 collate utf8_general_ci)



1 year ago by LuckyCyborg

Hi,

the correct order of the commands to initialize the database from a Nova application is

php forge migrate:install
php forge migrate
php forge db:seed
php forge module:migrate
php forge module:seed

Now, about the error about incorrect table definition, it is a known issue with some MySQL servers. Sadly, there is no universal solution.

How to fix that? You should manually modify your seeders, and for example instead of

        Schema::create('users', function (Blueprint $table)
        {
            $table->increments('id');
            $table->string('username', 100)->unique();
            $table->string('password');
            $table->string('email', 100)->unique();
            $table->string('remember_token')->nullable();
            $table->string('api_token', 100)->unique()->nullable();
            $table->timestamps();
        });

You should replace the timestamps(), as following:

        Schema::create('users', function (Blueprint $table)
        {
             $table->increments('id');
            $table->string('username', 100)->unique();
            $table->string('password');
            $table->string('email', 100)->unique();
            $table->string('remember_token')->nullable();
            $table->string('api_token', 100)->unique()->nullable();

            // Custom timestamps.
            $table->timestamp('created_at')->default('0000-00-00 00:00:00');
            $table->timestamp('updated_at')->default('0000-00-00 00:00:00');
        });

To note that you should adjust all migrations, before you can execute the console commands.


Login to reply.