2021-03-10 05:43:34 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2021-04-23 04:07:44 +00:00
|
|
|
"context"
|
2021-03-10 05:43:34 +00:00
|
|
|
"time"
|
|
|
|
|
2023-01-02 21:52:41 +00:00
|
|
|
"github.com/jackc/pgx/v5"
|
2021-03-10 05:43:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Migration interface {
|
|
|
|
Version() MigrationVersion
|
|
|
|
Name() string
|
|
|
|
Description() string
|
2021-04-23 04:07:44 +00:00
|
|
|
Up(ctx context.Context, conn pgx.Tx) error
|
|
|
|
Down(ctx context.Context, conn pgx.Tx) error
|
2021-03-10 05:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type MigrationVersion time.Time
|
|
|
|
|
|
|
|
func (v MigrationVersion) String() string {
|
|
|
|
return time.Time(v).Format(time.RFC3339)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v MigrationVersion) Before(other MigrationVersion) bool {
|
|
|
|
return time.Time(v).Before(time.Time(other))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v MigrationVersion) Equal(other MigrationVersion) bool {
|
|
|
|
return time.Time(v).Equal(time.Time(other))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v MigrationVersion) IsZero() bool {
|
|
|
|
return time.Time(v).IsZero()
|
|
|
|
}
|