3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.platform.db.migration;
22 import java.util.Date;
23 import javax.annotation.CheckForNull;
25 public interface DatabaseMigrationState {
27 String UNSUPPORTED_DATABASE_MIGRATION_STATUS = "Unsupported DatabaseMigration status";
28 String NO_CONNECTION_TO_DB = "Cannot connect to Database.";
31 NONE("NO_MIGRATION", "Database is up-to-date, no migration needed."),
32 RUNNING("MIGRATION_RUNNING", "Database migration is running."),
33 FAILED("MIGRATION_FAILED", "Migration failed: %s.<br/> Please check logs."),
34 SUCCEEDED("MIGRATION_SUCCEEDED", "Migration succeeded."),
35 STATUS_NOT_SUPPORTED("NOT_SUPPORTED", "Upgrade is not supported on embedded database."),
36 MIGRATION_REQUIRED("MIGRATION_REQUIRED", "Database migration is required. DB migration can be started using WS /api/system/migrate_db.");
38 private final String stringRepresentation;
39 private final String message;
41 Status(String stringRepresentation, String message) {
42 this.stringRepresentation = stringRepresentation;
43 this.message = message;
46 public String getMessage() {
51 public String toString() {
52 return stringRepresentation;
58 * Current status of the migration.
63 * The time and day the last migration was started.
65 * If no migration was ever started, the returned date is {@code null}.
68 * @return a {@link Date} or {@code null}
74 * The error of the last migration if it failed.
76 * @return a {@link Throwable} or {@code null}
82 * The amount of migrations already completed.
84 int getCompletedMigrations();
87 * The total amount of migrations to be performed.
89 int getTotalMigrations();
92 * The expected finish timestamp of the migration.
94 Date getExpectedFinishDate();