Skip to content

Commit

Permalink
fix: more explicit error when using sqlite driver with at least one c…
Browse files Browse the repository at this point in the history
…onstraint

Signed-off-by: Manfred Touron <[email protected]>
  • Loading branch information
moul committed Jul 14, 2020
1 parent 41c818f commit 7ae6e7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package sqlite

import "errors"

var (
ErrConstraintsNotImplemented = errors.New("constraints not implemented on sqlite, consider using DisableForeignKeyConstraintWhenMigrating, more details https://github.com/go-gorm/gorm/wiki/GORM-V2-Release-Note-Draft#all-new-migrator")
)
4 changes: 2 additions & 2 deletions migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ func (m Migrator) DropColumn(value interface{}, name string) error {
}

func (m Migrator) CreateConstraint(interface{}, string) error {
return gorm.ErrNotImplemented
return ErrConstraintsNotImplemented
}

func (m Migrator) DropConstraint(interface{}, string) error {
return gorm.ErrNotImplemented
return ErrConstraintsNotImplemented
}

func (m Migrator) HasConstraint(value interface{}, name string) bool {
Expand Down

0 comments on commit 7ae6e7d

Please sign in to comment.