Skip to content

Fix many-to-many tutorial code#1888

Merged
ricardograca merged 2 commits intobookshelf:masterfrom
ostriandoni:fix-tutorial-code
Aug 24, 2018
Merged

Fix many-to-many tutorial code#1888
ricardograca merged 2 commits intobookshelf:masterfrom
ostriandoni:fix-tutorial-code

Conversation

@ostriandoni
Copy link
Copy Markdown
Contributor

Introduction

When I try to implement code from this tutorial, I keep getting this error message:

$ knex migrate:latest

Knex:warning - migration file "20180824170607_initial_tables.js" failed
Knex:warning - migration failed with error: alter table `authors_books` add constraint `authors_books_author_id_foreign` foreign key (`author_id`) references `authors` (`id`) - ER_CANNOT_ADD_FOREIGN: Cannot add foreign key constraint

AND

$ knex migrate:rollback

Knex:warning - migration file "20180824170607_initial_tables.js" failed
Knex:warning - migration failed with error: drop table `books` - ER_ROW_IS_REFERENCED: Cannot delete or update a parent row: a foreign key constraint fails

Motivation

To make the tutorial code running as expected.

Proposed solution

Current PR Issues

None

Alternatives considered

None

@ricardograca
Copy link
Copy Markdown
Member

There is still a chance that this migration will fail with clients other than SQLite or when using a connection pool with more than 1 connection, but it's still an improvement, so many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants