Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[11.x] SQLite Error: "General error: 1 no such table" after adding a foreign key when using a table prefix. #52578

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

incrize
Copy link
Contributor

@incrize incrize commented Aug 26, 2024

How to reproduce:

  1. Set the table prefix: tprefix_

  2. Run:

Schema::create('table_users', function (Blueprint $table) {
    $table->id();
    $table->timestamps();
});

Schema::create('table_posts', function (Blueprint $table) {
    $table->id();
    $table->foreignId('author_id')->constrained('table_users');
    $table->timestamps();
});

Schema::table('table_posts', function (Blueprint $table) {
    $table->foreignId('moderator_id')->constrained('table_users');
});

Error:

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: main.tprefix_tprefix_table_users (Connection: sqlite, SQL: insert into "__temp__tprefix_table_posts" ("id", "author_id", "created_at", "updated_at", "moderator_id") select "id", "author_id", "created_at", "updated_at", "moderator_id" from "tprefix_table_posts")

@incrize
Copy link
Contributor Author

incrize commented Aug 26, 2024

#51373

@taylorotwell taylorotwell merged commit 85b7ca8 into laravel:11.x Sep 3, 2024
29 checks passed
hafezdivandari added a commit to hafezdivandari/framework that referenced this pull request Sep 6, 2024
…dding a foreign key when using a table prefix. (laravel#52578)"

This reverts commit 85b7ca8.
hafezdivandari added a commit to hafezdivandari/framework that referenced this pull request Sep 6, 2024
taylorotwell pushed a commit that referenced this pull request Sep 6, 2024
* Revert "[11.x] SQLite Error: "General error: 1 no such table" after adding a foreign key when using a table prefix. (#52578)"

This reverts commit 85b7ca8.

* fixes #52578

* fixes #52655

* formatting
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants