Beispiel #1
0
//MigrateDown reverts an existing schema to the previously know version
func MigrateDown(repo files.IFileRepo,
	service versioning.IManageVersions) error {

	migFiles, err := repo.FindAll()
	if err != nil {
		return err
	}

	currentV, err := service.GetCurrentVersion()
	if err != nil {
		return err
	}

	if currentV > 0 {
		s := find(currentV, migFiles)
		return migrateDown(s, service)
	}

	return nil
}
Beispiel #2
0
//MigrateUp updates the schema to the latest based on available changes
func MigrateUp(repo files.IFileRepo,
	service versioning.IManageVersions) error {

	migFiles, err := repo.FindAll()
	if err != nil {
		return err
	}

	currentV, err := service.GetCurrentVersion()
	if err != nil {
		return err
	}

	migratables := getMigratable(currentV, migFiles)

	migCnt := len(migratables)
	if migCnt > 0 {
		fmt.Printf("Migrating %d files...\n", migCnt)
		return migrateUp(service, migratables)
	}

	return nil
}