36 lines
632 B
Go
36 lines
632 B
Go
//go:generate sqlc generate
|
|
package sqlc
|
|
|
|
import (
|
|
"embed"
|
|
"time"
|
|
|
|
_ "github.com/golang-migrate/migrate/v4/database/sqlite"
|
|
"github.com/golang-migrate/migrate/v4/source"
|
|
"github.com/golang-migrate/migrate/v4/source/iofs"
|
|
)
|
|
|
|
//go:embed migrations/*.sql
|
|
var migrations embed.FS
|
|
|
|
func Migrations() (source.Driver, error) {
|
|
d, err := iofs.New(migrations, "migrations")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return d, nil
|
|
}
|
|
|
|
type Timestamp int64
|
|
|
|
func (t Timestamp) Time() time.Time {
|
|
return time.UnixMilli(int64(t))
|
|
}
|
|
|
|
func (t Timestamp) String() string {
|
|
if t == 0 {
|
|
return "None"
|
|
}
|
|
return t.Time().Format("01/02/2006")
|
|
}
|