Skip to content
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

sql/mysql: allow extending procs/funcs migrate plan #2185

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions sql/mysql/driver_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,39 @@ func (*state) renameView(*schema.RenameView) {
func (d *diff) ViewAttrChanged(_, _ *schema.View) bool {
return false // Not implemented.
}

func (s *state) addFunc(*schema.AddFunc) error {
return nil // unimplemented.
}

func (s *state) dropFunc(*schema.DropFunc) error {
return nil // unimplemented.
}

func (s *state) modifyFunc(*schema.ModifyFunc) error {
return nil // unimplemented.
}

func (s *state) renameFunc(*schema.RenameFunc) error {
return nil // unimplemented.
}

func (s *state) addProc(*schema.AddProc) error {
return nil // unimplemented.
}

func (s *state) dropProc(*schema.DropProc) error {
return nil // unimplemented.
}

func (s *state) modifyProc(*schema.ModifyProc) error {
return nil // unimplemented.
}

func (s *state) renameProc(*schema.RenameProc) error {
return nil // unimplemented.
}

func verifyChanges(context.Context, []schema.Change) error {
return nil // unimplemented.
}
17 changes: 16 additions & 1 deletion sql/mysql/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
type planApply struct{ *conn }

// PlanChanges returns a migration plan for the given schema changes.
func (p *planApply) PlanChanges(_ context.Context, name string, changes []schema.Change, opts ...migrate.PlanOption) (*migrate.Plan, error) {
func (p *planApply) PlanChanges(ctx context.Context, name string, changes []schema.Change, opts ...migrate.PlanOption) (*migrate.Plan, error) {
s := &state{
conn: p.conn,
Plan: migrate.Plan{
Expand All @@ -41,6 +41,9 @@ func (p *planApply) PlanChanges(_ context.Context, name string, changes []schema
for _, o := range opts {
o(&s.PlanOptions)
}
if err := verifyChanges(ctx, changes); err != nil {
return nil, err
}
if err := s.plan(changes); err != nil {
return nil, err
}
Expand Down Expand Up @@ -93,6 +96,18 @@ func (s *state) plan(changes []schema.Change) error {
err = s.modifyTable(c)
case *schema.RenameTable:
s.renameTable(c)
case *schema.AddFunc:
err = s.addFunc(c)
case *schema.AddProc:
err = s.addProc(c)
case *schema.ModifyFunc:
err = s.modifyFunc(c)
case *schema.ModifyProc:
err = s.modifyProc(c)
case *schema.DropFunc:
err = s.dropFunc(c)
case *schema.DropProc:
err = s.dropProc(c)
case *schema.AddView, *schema.DropView, *schema.ModifyView, *schema.RenameView:
views = append(views, c)
default:
Expand Down