Skip to content

Conversation

jyrkidn
Copy link
Contributor

@jyrkidn jyrkidn commented Sep 22, 2021

This syntax is currently generating a wrong migration

models:
  Event:
    working_title: string
    image_id: uuid foreign:\Foo\Bar\Attachment
$table->foreign('image_id')->references('id')->on('\Foo\Bar\Attachments');

This makes that inserting record in mysql will fail, since \Foo\Bar\Attachments is not an existing table.

The changes in this pull request will fix this.

New output will be

$table->foreignUuid('image_id')->constrained('attachments');

@jasonmccreary
Copy link
Collaborator

@jyrkidn, can you update the PR details with the "fixed" output...

@jyrkidn
Copy link
Contributor Author

jyrkidn commented Sep 23, 2021

Fixed output has been added and tests have been updated after the changes on master.

Copy link
Collaborator

@jasonmccreary jasonmccreary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this approach works in all cases...

@jasonmccreary jasonmccreary merged commit 07a0855 into laravel-shift:master Sep 23, 2021
@jasonmccreary
Copy link
Collaborator

Awesome. Thanks!

@jyrkidn
Copy link
Contributor Author

jyrkidn commented Sep 23, 2021

Thanks for reviewing and merging my pull requests. Very much appreciated!

@jyrkidn jyrkidn deleted the feature/replace-classname-to-table-for-migration-constraint branch September 24, 2021 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants