コード例 #1
0
ファイル: status.go プロジェクト: karver/karver
func statusCmd(c *cli.Context) {
	migrationsPath := c.GlobalString("migrations")
	targetPath := c.GlobalString("target")

	migrationsPath, err := migrations.AbsMigrationsPath(migrationsPath)
	if err != nil {
		fmt.Printf("Error determining the migrations path: %s\n", err.Error())
		os.Exit(1)
	}

	list, err := migrations.List(migrationsPath)
	if err != nil {
		fmt.Printf("Error listing the available migrations: %s\n", err.Error())
		os.Exit(1)
	}

	timestamp, err := migrations.CurrentTimestamp(targetPath)
	if err != nil {
		fmt.Printf("Error reading the current timestamp: %s\n", err.Error())
		os.Exit(1)
	}

	if last := migrations.Last(list, timestamp); last != nil {
		fmt.Printf("Last migration executed: %s\n", last.Name)
	} else {
		fmt.Printf("No migration executed yet!\n")
	}

	fmt.Printf("Pending migrations: %d\n", len(migrations.Pending(list, timestamp)))
}
コード例 #2
0
ファイル: run.go プロジェクト: karver/karver
func runCmd(c *cli.Context) {
	migrationsPath := c.GlobalString("migrations")
	targetPath := c.GlobalString("target")

	migrationsPath, err := migrations.AbsMigrationsPath(migrationsPath)
	if err != nil {
		log.Fatal("Error determining the migrations path: " + err.Error())
		os.Exit(1)
	}

	list, err := migrations.List(migrationsPath)
	if err != nil {
		log.Fatal("Error listing the available migrations: " + err.Error())
		os.Exit(1)
	}

	timestamp, err := migrations.CurrentTimestamp(targetPath)
	if err != nil {
		log.Fatal("Error reading the current timestamp: " + err.Error())
		os.Exit(1)
	}

	pending := migrations.Pending(list, timestamp)

	migrations.Run(pending, targetPath)
}