fix: more explicit error when using sqlite driver with at least one constraint

Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
This commit is contained in:
Manfred Touron
2020-07-15 00:12:30 +02:00
parent 41c818fc36
commit 7ae6e7d479
2 changed files with 9 additions and 2 deletions

7
errors.go Normal file
View File

@@ -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")
)

View File

@@ -149,11 +149,11 @@ func (m Migrator) DropColumn(value interface{}, name string) error {
} }
func (m Migrator) CreateConstraint(interface{}, string) error { func (m Migrator) CreateConstraint(interface{}, string) error {
return gorm.ErrNotImplemented return ErrConstraintsNotImplemented
} }
func (m Migrator) DropConstraint(interface{}, string) error { func (m Migrator) DropConstraint(interface{}, string) error {
return gorm.ErrNotImplemented return ErrConstraintsNotImplemented
} }
func (m Migrator) HasConstraint(value interface{}, name string) bool { func (m Migrator) HasConstraint(value interface{}, name string) bool {