migrator.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package gorm
  2. import (
  3. "database/sql"
  4. )
  5. // ViewOption view option
  6. type ViewOption struct {
  7. Replace bool
  8. CheckOption string
  9. Query *DB
  10. }
  11. type Migrator interface {
  12. // AutoMigrate
  13. AutoMigrate(dst ...interface{}) error
  14. // Tables
  15. CreateTable(dst ...interface{}) error
  16. DropTable(dst ...interface{}) error
  17. HasTable(dst ...interface{}) error
  18. RenameTable(oldName, newName string) error
  19. // Columns
  20. AddColumn(dst interface{}, field string) error
  21. DropColumn(dst interface{}, field string) error
  22. AlterColumn(dst interface{}, field string) error
  23. RenameColumn(dst interface{}, oldName, field string) error
  24. ColumnTypes(dst interface{}) ([]*sql.ColumnType, error)
  25. // Views
  26. CreateView(name string, option ViewOption) error
  27. DropView(name string) error
  28. // Constraints
  29. CreateConstraint(dst interface{}, name string) error
  30. DropConstraint(dst interface{}, name string) error
  31. // Indexes
  32. CreateIndex(dst interface{}, name string) error
  33. DropIndex(dst interface{}, name string) error
  34. HasIndex(dst interface{}, name string) error
  35. RenameIndex(dst interface{}, oldName, newName string) error
  36. }