github.com/Accefy/pop@v0.0.0-20230428174248-e9f677eab5b9/schema_migrations.go (about)

     1  //go:build !appengine
     2  // +build !appengine
     3  
     4  package pop
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/gobuffalo/fizz"
    10  )
    11  
    12  func newSchemaMigrations(name string) fizz.Table {
    13  	tab := fizz.Table{
    14  		Name: name,
    15  		Columns: []fizz.Column{
    16  			{
    17  				Name:    "version",
    18  				ColType: "string",
    19  				Options: map[string]interface{}{
    20  					"size": 14, // len(YYYYMMDDhhmmss)
    21  				},
    22  			},
    23  		},
    24  		Indexes: []fizz.Index{
    25  			{Name: fmt.Sprintf("%s_version_idx", name), Columns: []string{"version"}, Unique: true},
    26  		},
    27  	}
    28  	// this is for https://github.com/gobuffalo/pop/issues/659.
    29  	// primary key is not necessary for the migration table but it looks like
    30  	// some database engine versions requires it for index.
    31  	tab.PrimaryKey("version")
    32  	return tab
    33  }