> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration guide

## 4.1.3-AS6.1 to 5.0.0-AS6.1

Migrate from Atoti What-If 4.1.3-AS6.1 to 5.0.0-AS6.1. Consult the Atoti What-If 5.0.0-AS6.1 [release notes](./release-notes) and [changelog](./changelog) for a complete view of changes.

### Database schema migration

This release adds a `PARENTBRANCH` column to the `DATASTORE_SIMULATIONS` table to support chaining branches of what-if simulations.

#### Automatic migration (Liquibase)

Atoti What-If now uses [Liquibase](https://www.liquibase.com/) to manage schema migrations. If your application uses the provided Liquibase changelog, the migration is applied automatically on startup:

```sql theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
ALTER TABLE DATASTORE_SIMULATIONS ADD PARENTBRANCH VARCHAR(255);
```

Liquibase tracks applied changesets in the `DATABASECHANGELOG` table, so this statement is only ever executed once per database.

#### Manual migration

If you manage your database schema manually, run the following SQL against your `SUBMISSIONS` schema before starting the application:

```sql theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
ALTER TABLE DATASTORE_SIMULATIONS ADD PARENTBRANCH VARCHAR(255);
```

### Overview

Atoti What-If 5.0.0 introduces a Spring Boot Starter that auto-configures all necessary beans. This is a major release that simplifies integration while removing several deprecated classes and methods.

### Recommended migration process

1. Back up your project.
2. Update the Atoti What-If dependency to use the Spring Boot Starter.
3. Provide the required beans (`IDatabaseService` and `IWhatIfPersistenceProperties`).
4. Remove manual bean definitions that are now auto-configured.
5. Configure properties in `application.yml` or `application.properties`.
6. Update code using removed classes, methods, or constructors.
7. Confirm successful build and startup.

### Update dependencies

#### Update Atoti What-If to version 5.0.0-AS6.1

Replace the old dependency with the new Spring Boot Starter:

* Atoti What-If 4.1.3-AS6.1:

```xml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
<dependency>
    <groupId>com.activeviam.apps</groupId>
    <artifactId>whatif</artifactId>
    <version>4.1.3-AS6.1</version>
</dependency>
```

* Atoti What-If 5.0.0-AS6.1:

```xml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
<dependency>
    <groupId>com.activeviam.apps</groupId>
    <artifactId>atoti-what-if-spring-boot-starter</artifactId>
    <version>5.0.0-AS6.1</version>
</dependency>
```

### Provide required beans

The Spring Boot Starter requires two beans from your application:

#### IDatabaseService

Provided by your Atoti Server application:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public IDatabaseService databaseService(IDatastore datastore) {
    return new DatabaseService(datastore);
}
```

#### IWhatIfPersistenceProperties

Provides Hibernate configuration for simulation persistence:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public IWhatIfPersistenceProperties whatIfPersistenceProperties(
        @Value("classpath:hibernate.properties") Resource resource) throws IOException {
    Properties props = new Properties();
    props.load(resource.getInputStream());
    return () -> props.entrySet().stream()
        .collect(Collectors.toMap(
            e -> String.valueOf(e.getKey()),
            e -> String.valueOf(e.getValue())
        ));
}
```

### Remove manual bean definitions

The following beans are now auto-configured and should be removed from your configuration:

| Bean                                  | Auto-configuration class  |
| ------------------------------------- | ------------------------- |
| `DatabaseSimulationEngine`            | `WhatIfCoreConfig`        |
| `IUniqueIdGenerator`                  | `WhatIfCoreConfig`        |
| `ISimulationPersistenceManager`       | `WhatIfPersistenceConfig` |
| `IDatabaseSimulationsSecurityManager` | `WhatIfSecurityConfig`    |
| `IDatabaseSimulationsWorkflow`        | `WhatIfWorkflowConfig`    |
| `DatabaseSimulationsRestService`      | `WhatIfRestConfig`        |

To override any auto-configured bean, define your own bean of the same type. All auto-configured beans use `@ConditionalOnMissingBean`.

### Configure properties

Security and distribution settings are now managed through properties:

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
atoti:
  what-if:
    security:
      type: spring  # spring (default), none, or custom
      use-branch-permissions: true
    distribution:
      enabled: false
      query-node-name: ""
      create-distributed-service: true
```

See the [configuration reference](../dev-getting-started/configuration-reference) for all available properties.

### Removed classes

#### DatabaseSimulationPersistenceManager

`DatabaseSimulationPersistenceManager` has been removed. Use `HibernateSimulationPersistenceManager` instead.

* Before:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Bean
public ISimulationPersistenceManager persistenceManager(IDatabaseService databaseService) {
    return new DatabaseSimulationPersistenceManager(databaseService);
}
```

* After:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
// Auto-configured by the starter, or manually:
@Bean
public ISimulationPersistenceManager persistenceManager() {
    return new HibernateSimulationPersistenceManager<>(DatabaseSimulationJPA.class);
}
```

#### Exception classes in DatabaseSimulationsRestService

The inner exception classes in `DatabaseSimulationsRestService` have been removed. Use the standalone classes in `com.activeviam.tools.whatif.rest` instead:

| Removed class                                                         | Replacement                                                             |
| --------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `DatabaseSimulationsRestService.ActiveViamSimulationException`        | `com.activeviam.tools.whatif.rest.ActiveViamSimulationException`        |
| `DatabaseSimulationsRestService.ActiveViamUnauthorizedException`      | `com.activeviam.tools.whatif.rest.ActiveViamUnauthorizedException`      |
| `DatabaseSimulationsRestService.ActiveViamDeletionException`          | `com.activeviam.tools.whatif.rest.ActiveViamDeletionException`          |
| `DatabaseSimulationsRestService.ActiveViamUnknownSimulationException` | `com.activeviam.tools.whatif.rest.ActiveViamUnknownSimulationException` |

### Removed constructors

#### RestDistributedDatabaseService

The constructors accepting a `distributedPivot` parameter have been removed. Use the constructors without the pivot parameter.

* Before:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
new RestDistributedDatabaseService(addresses, authenticator, distributedPivot);
new RestDistributedDatabaseService(resultsMerger, addresses, authenticator, distributedPivot);
```

* After:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
new RestDistributedDatabaseService(addresses, authenticator);
new RestDistributedDatabaseService(resultsMerger, addresses, authenticator);
// Or let the starter auto-configure it when distribution.enabled: true
```

### Removed methods

#### RestDistributedDatabaseService.isConsistentStatus()

The `isConsistentStatus()` method has been removed.

### Constructor changes

If you are instantiating classes directly (without the starter), note the following changes:

#### DatabaseSimulationsRestService

`DatabaseSimulationsRestService` now uses constructor injection with three required parameters:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
new DatabaseSimulationsRestService(
    simulationsPersistenceManager,
    simulationsWorkflow,
    databaseService
);
```

#### DatabaseSimulationsWorkflow

`DatabaseSimulationsWorkflow` now uses constructor injection with five required parameters:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
new DatabaseSimulationsWorkflow(
    engine,
    databaseSimulationPersistenceManager,
    securityManager,
    databaseService,
    databaseSimulationIdGenerator
);
```
