2018-09-24 09:53:16 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2018-11-17 06:21:39 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/context"
|
2019-05-02 14:10:05 +02:00
|
|
|
log "github.com/sirupsen/logrus"
|
2018-09-24 09:53:16 +02:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
2018-11-17 13:57:19 +01:00
|
|
|
// Automatically migrates / initializes database
|
2018-09-24 09:53:16 +02:00
|
|
|
var MigrateCommand = cli.Command{
|
2018-09-27 08:59:53 +02:00
|
|
|
Name: "migrate",
|
|
|
|
Usage: "Automatically migrates / initializes database",
|
2018-09-24 09:53:16 +02:00
|
|
|
Action: migrateAction,
|
|
|
|
}
|
|
|
|
|
2018-11-17 06:21:39 +01:00
|
|
|
func migrateAction(ctx *cli.Context) error {
|
2019-05-03 18:57:28 +02:00
|
|
|
app := context.NewContext( ctx)
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2019-05-02 14:10:05 +02:00
|
|
|
log.Infoln("migrating database")
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2019-05-03 18:57:28 +02:00
|
|
|
app.MigrateDb()
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2019-05-02 14:10:05 +02:00
|
|
|
log.Infoln("database migration complete")
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|