This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

webmaster
webmaster

Hello,

I read many docs before submiting this post. when I trying to run migration file plugin:refresh I recieving error which not allow me to create foreign keys.

there are no problem on my syntax and etc...


$this->down();

        Schema::create('me_texts_full_plots' , function ($table)
        {
            $table->increments('id');
            $table->integer('title_id')->unsigned();
            $table->text('content');
            $table->boolean('is_published')->default(false);
            $table->tinyInteger('status')->unsigned();

        });

        Schema::create('me_texts_short_plots' , function ($table)
        {
            $table->increments('id');
            $table->integer('title_id')->unsigned();
            $table->text('content');
            $table->boolean('is_published')->default(false);
            $table->tinyInteger('status')->unsigned();
        });

        Schema::create('me_titles' , function ($table)
        {
            $table->increments('id');
            $table->integer('short_plot_id')->length(10)->unsigned();
            $table->integer('full_plot_id')->length(10)->unsigned();
            $table->boolean('is_published')->default(false)->index();
            $table->tinyInteger('status')->unsigned()->nullable();
            $table->softDeletes();
        });

        Schema::table('me_titles', function ($table)
        {
            $table->foreign('short_plot_id')->refrences('id')->on('me_texts_short_plots')->onDelete('cascade');
            $table->foreign('full_plot_id')->refrences('id')->on('me_texts_full_plots')->onDelete('cascade');
        });

any one know what can i do?

Last updated

raw99
raw99

Try to replace: $table->integer('short_plot_id')->length(10)->unsigned(); $table->integer('full_plot_id')->length(10)->unsigned(); with: $table->integer('short_plot_id')->unsigned(); $table->integer('full_plot_id')->unsigned();

Why there is $this->down(); in top of your code, btw?

Last updated

webmaster
webmaster

Thanks raw,

it because some times I received error of table exist when used plugin:refresh command.

I test this way and not work :(

raw99
raw99

webmaster said:

Thanks raw,

it because some times I received error of table exist when used plugin:refresh command.

I test this way and not work :(

Ok, I have done same mistake as you. You forgot about $table->engine = 'InnoDB'; for table "me_titles"... :)

Last updated

wellyfrs
wellyfrs

You are using refrences instead of references.

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.