preparing for task dependency implementation

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-05 08:49:25 +02:00
parent dd1ba104e3
commit 91f536a658
4 changed files with 29 additions and 6 deletions

View File

@@ -5,9 +5,12 @@ public class Constants {
private Constants(){}
public static final String CONFIG_DATABASE = "umbrella.modules.task.database";
public static final String CHILDREN = "children";
public static final String ESTIMATED_TIMES = "estimated_times";
public static final String REQUIRED_TASK_ID = "required_task_id";
public static final String TABLE_TASK_DEPENDENCIES = "task_dependencies";
public static final String TABLE_TASKS = "tasks";
public static final String TABLE_TASKS_USERS = "tasks_users";
public static final String TASK = "task";

View File

@@ -35,16 +35,31 @@ public class SqliteDb extends BaseDb implements TaskDb {
int currentVersion = createSettingsTable();
switch (currentVersion){
case 0:
createTaskTables();
createTaskTable();
createTasksUsersTable();
case 1:
swapStates(TABLE_TASKS);
case 2:
createDependencyTable();
}
return setCurrentVersion(2);
return setCurrentVersion(3);
}
private void createTaskTables() {
private void createDependencyTable() {
var sql = "CREATE TABLE IF NOT EXISTS {0} ({1} INT NOT NULL, {2} INT NOT NULL, PRIMARY KEY({1}, {2}))";
sql = format(sql,TABLE_TASK_DEPENDENCIES,TASK_ID,REQUIRED_TASK_ID);
try {
var stmt = db.prepareStatement(sql);
stmt.execute();
stmt.close();
} catch (SQLException e) {
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_TASK_DEPENDENCIES, e);
throw new RuntimeException(e);
}
}
private void createTaskTable() {
var createTable = """
CREATE TABLE IF NOT EXISTS "{0}" (
{1} INTEGER PRIMARY KEY,