Use goose for migrations

This commit is contained in:
2021-11-08 22:24:21 +00:00
parent cf1bc70103
commit 5de7d32c30
25 changed files with 134 additions and 145 deletions

27
postgres/ulid.go Normal file
View File

@ -0,0 +1,27 @@
package postgres
import (
"math/rand"
"time"
"github.com/oklog/ulid"
)
type UlidGenerator struct {
time time.Time
entropy *rand.Rand
}
func NewGenerator() (*UlidGenerator, error) {
t := time.Time{}
ug := &UlidGenerator{
time: t,
entropy: rand.New(rand.NewSource(t.UnixNano())),
}
return ug, nil
}
func (ug *UlidGenerator) New() string {
id := ulid.MustNew(ulid.Timestamp(time.Now()), ug.entropy)
return id.String()
}