package com.atlassian.bitbucket.ao;

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.sal.api.transaction.TransactionCallback;

/**
 * Represents {@link com.atlassian.activeobjects.external.ActiveObjects Active Objects} upgrade subtask.
 *
 * @see AbstractActiveObjectsCompositeUpgradeTask
 */
public interface ActiveObjectsUpgradeSubtask {
    /**
     * @return name of upgrade subtask that will be used to identify it in logs
     */
    String getName();

    /**
     * Perform upgrade process.
     * <p>
     * This method's execution is wrapped into {@link ActiveObjects#executeInTransaction(TransactionCallback)}
     * so implementing class should not call it another time as that will cause an exception in runtime.
     * <p>
     * Any exception thrown will rollback whole parent upgrade task.
     */
    void upgrade(ActiveObjects ao);
}
