github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/plugins/tools/soda/creator.go (about)

     1  package soda
     2  
     3  import (
     4  	"github.com/wawandco/ox/plugins/tools/soda/fizz"
     5  	"github.com/wawandco/ox/plugins/tools/soda/sql"
     6  )
     7  
     8  var _ Creator = fizz.Creator{}
     9  var _ Creator = sql.Creator{}
    10  
    11  type Creator interface {
    12  	// Receives a migration type string and returns if it
    13  	// applies to it or not.
    14  	Creates(string) bool
    15  
    16  	// Creates the migration.
    17  	Create(dir, name string, args []string) error
    18  }
    19  
    20  type Creators []Creator
    21  
    22  func (c Creators) CreatorFor(name string) Creator {
    23  	for _, x := range c {
    24  		if x.Creates(name) {
    25  			return x
    26  		}
    27  	}
    28  
    29  	return nil
    30  }