use of com.palantir.stash.stashbot.jobtemplate.JobType in project stashbot by palantir.
the class ConfigurationV2UpgradeTask method upgrade.
/* This is safe to do because the ao.migrate() API uses varargs with a templated type
* and there's no way around that, but it's just classes and how the API works, so I
* think it's safe.
*/
@SuppressWarnings("unchecked")
@Override
public void upgrade(ModelVersion currentVersion, ActiveObjects ao) {
if (!currentVersion.isSame(ModelVersion.valueOf("1"))) {
throw new IllegalStateException("ConfigurationV2UpgradeTask can only upgrade from version 1");
}
// Migrate the old table to base the info off it.
ao.migrate(RepositoryConfiguration.class);
// Migrate the new table so we can populate it
ao.migrate(JobTypeStatusMapping.class);
for (RepositoryConfiguration rc : ao.find(RepositoryConfiguration.class)) {
for (JobType jt : ImmutableList.of(JobType.PUBLISH, JobType.VERIFY_COMMIT, JobType.VERIFY_PR)) {
ao.create(JobTypeStatusMapping.class, new DBParam("REPO_CONFIG_ID", rc.getID()), new DBParam("IS_ENABLED", true), new DBParam("JOB_TYPE_RAW", jt.name()));
}
}
}
Aggregations