Skip to content

Support dropping foreign key #50

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2023
Merged

Support dropping foreign key #50

merged 1 commit into from
Jul 4, 2023

Conversation

youpy
Copy link
Contributor

@youpy youpy commented Jun 30, 2023

  • Add DropKeyMapper that returns keywords in foreign key deletion based on key type

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (6c0a31b) 100.00% compared to head (c0a70b4) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #50   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          624       629    +5     
=========================================
+ Hits           624       629    +5     
Impacted Files Coverage Δ
builder/table.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Fs02
Copy link
Member

Fs02 commented Jul 2, 2023

Hi, thanks for the PR

can you give example what's the use case for mapper? thanks

@youpy
Copy link
Contributor Author

youpy commented Jul 3, 2023

Thanks for the review.

can you give example what's the use case for mapper?

For the MySQL adapter, DropKeyMapper would look like this:

func DropKeyMapper(keyType rel.KeyType) string {
  if keyType == rel.ForeignKey {
    // see https://dev.mysql.com/doc/refman/8.0/ja/alter-table.html
    return "FOREIGN KEY"
  }

  // unsupported key type
  // (maybe we should return an error here)
  return ""
}

Copy link
Member

@Fs02 Fs02 left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks

@Fs02 Fs02 changed the title support dropping foreign key Support dropping foreign key Jul 4, 2023
@Fs02 Fs02 merged commit dd905c4 into go-rel:main Jul 4, 2023
@Fs02
Copy link
Member

Fs02 commented Jul 4, 2023

will you update the other adapters too?

@youpy
Copy link
Contributor Author

youpy commented Jul 4, 2023

will you update the other adapters too?

yes I will.

youpy added a commit to youpy/mysql that referenced this pull request Jul 7, 2023
- update `github.com/go-rel/sql` to the latest version
- go-rel/sql#50
Fs02 pushed a commit to go-rel/mysql that referenced this pull request Jul 8, 2023
* Support dropping foreign key

- update `github.com/go-rel/sql` to the latest version
- go-rel/sql#50

* Unsupported key types cause panic instead of returning ""

* Add test for panic on unsupported key drop
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