2020-02-10 07:46:58 +01:00
|
|
|
/*
|
2022-11-11 05:49:16 +01:00
|
|
|
* Copyright © 2020-2021 Musing Studio LLC.
|
2020-02-10 07:46:58 +01:00
|
|
|
*
|
|
|
|
* This file is part of WriteFreely.
|
|
|
|
*
|
|
|
|
* WriteFreely is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, included
|
|
|
|
* in the LICENSE file in this source code package.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/urfave/cli/v2"
|
2021-04-06 23:24:07 +02:00
|
|
|
"github.com/writefreely/writefreely"
|
2020-02-10 07:46:58 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
cmdDB cli.Command = cli.Command{
|
|
|
|
Name: "db",
|
|
|
|
Usage: "db management tools",
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
&cmdDBInit,
|
|
|
|
&cmdDBMigrate,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cmdDBInit cli.Command = cli.Command{
|
2020-03-02 19:59:32 +01:00
|
|
|
Name: "init",
|
|
|
|
Usage: "Initialize Database",
|
2020-02-10 07:46:58 +01:00
|
|
|
Action: initDBAction,
|
|
|
|
}
|
|
|
|
|
|
|
|
cmdDBMigrate cli.Command = cli.Command{
|
2020-03-02 19:59:32 +01:00
|
|
|
Name: "migrate",
|
|
|
|
Usage: "Migrate Database",
|
|
|
|
Action: migrateDBAction,
|
2020-02-10 07:46:58 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func initDBAction(c *cli.Context) error {
|
|
|
|
app := writefreely.NewApp(c.String("c"))
|
|
|
|
return writefreely.CreateSchema(app)
|
|
|
|
}
|
|
|
|
|
|
|
|
func migrateDBAction(c *cli.Context) error {
|
|
|
|
app := writefreely.NewApp(c.String("c"))
|
|
|
|
return writefreely.Migrate(app)
|
2020-03-02 19:59:32 +01:00
|
|
|
}
|