26 lines
514 B
Go
26 lines
514 B
Go
|
package migrations
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
|
||
|
"go.jolheiser.com/invitea/database/sqlc"
|
||
|
|
||
|
"github.com/golang-migrate/migrate/v4"
|
||
|
"github.com/golang-migrate/migrate/v4/database/sqlite"
|
||
|
_ "modernc.org/sqlite"
|
||
|
)
|
||
|
|
||
|
func New(db *sql.DB) (*migrate.Migrate, error) {
|
||
|
migrations, err := sqlc.Migrations()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
instance, err := sqlite.WithInstance(db, &sqlite.Config{})
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return migrate.NewWithInstance("sqlite", migrations, "invitea", instance)
|
||
|
}
|