PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved

Error on migration by MySql 8 DB

Solved
orgaborweb

Nov 4th, 2024 10:58 PM

Hello, First of all wave is amazing, however I have some issues if I try to use mysql istead of sqlite. First if all I'm getting the following error, as the table plans does not exists when the subscriptions table is beeing created:

SQLSTATE[HY000]: General error: 1824 Failed to open the referenced table 'plans' (Connection: mysql, SQL: alter table `subscriptions` add constraint `subscriptions_plan_id_foreign` foreign key (`plan_id`) references `plans` (`id`) on delete cascade)

This is managable if I change the order and setting plans before subscriptions BUT if I do so, I'm getting the next error:

SQLSTATE[HY000]: General error: 3780 Referencing column 'plan_id' and referenced column 'id' in foreign key constraint 'subscriptions_plan_id_foreign' are incompatible. (Connection: mysql, SQL: alter table `subscriptions` add constraint `subscriptions_plan_id_foreign` foreign key (`plan_id`) references `plans` (`id`) on delete cascade)

Please assist how to manage this issue. Thank you! Cheers, Gabor

UPDATE:

I managed to solve the issue as follows:

  • Change the order of plans and subscriptions table
  • Change the datatype if the plan id on plans table to $table->unsignedBigInteger('id')->primary();
  • In subscriptions table comment out the following line $table->unsignedBigInteger('plan_id');
  • Modify the last line $table->foreign('plan_id')->references('id')->on('plans')->onDelete('cascade'); TO $table->foreignId('plan_id')->references('id')->on('plans')->onDelete('cascade');

SIDENOTE: This is only for the migration issue, I was not able to test in the app yet.

Cheers, Gabor

bobbyiliev

Nov 4th, 2024 11:12 PM

Best Answer

Hey!

Ah yes, we have a PR from a community member that patches that problem.

You can cherry pick the change from here:

https://github.com/thedevdojo/wave/pull/138

We will be merging this soon as well!

- Bobby

Report
1