added relative_path column to DiffTasks table

This commit is contained in:
Jonathan Treffler 2024-01-23 21:59:41 +01:00 committed by root
parent 0a25d57705
commit 93cf10d00d

View file

@ -9,93 +9,96 @@
class Version100Date20230822153000 extends SimpleMigrationStep { class Version100Date20230822153000 extends SimpleMigrationStep {
const TASKS_TABLE = "groupfolder_snapshots_tasks"; const TASKS_TABLE = "groupfolder_snapshots_tasks";
const RESULTS_TABLE = "groupfolder_snapshots_task_results"; const RESULTS_TABLE = "groupfolder_snapshots_task_results";
/** /**
* @param IOutput $output * @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
if (!$schema->hasTable(self::TASKS_TABLE)) { if (!$schema->hasTable(self::TASKS_TABLE)) {
$table = $schema->createTable(self::TASKS_TABLE); $table = $schema->createTable(self::TASKS_TABLE);
$table->addColumn('id', 'integer', [ $table->addColumn('id', 'integer', [
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('user_id', 'string', [ $table->addColumn('user_id', 'string', [
'notnull' => true, 'notnull' => true,
'length' => 200, 'length' => 200,
]); ]);
$table->addColumn('groupfolder_id', 'bigint', [ $table->addColumn('groupfolder_id', 'bigint', [
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('snapshot_id', 'string', [ $table->addColumn('relative_path', 'string', [
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('snapshot_id', 'string', [
$table->addColumn('timestamp', 'integer', [ 'notnull' => true,
]);
$table->addColumn('timestamp', 'integer', [
'notnull' => true, 'notnull' => true,
'default' => 0, 'default' => 0,
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'userid_index'); $table->addIndex(['user_id'], 'userid_index');
$table->addIndex(['groupfolder_id'], 'groupfolderid_index'); $table->addIndex(['groupfolder_id'], 'groupfolderid_index');
} }
if (!$schema->hasTable(self::RESULTS_TABLE)) { if (!$schema->hasTable(self::RESULTS_TABLE)) {
$table = $schema->createTable(self::RESULTS_TABLE); $table = $schema->createTable(self::RESULTS_TABLE);
$table->addColumn('id', 'integer', [ $table->addColumn('id', 'integer', [
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('task_id', 'integer', [ $table->addColumn('task_id', 'integer', [
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('type', 'string', [ $table->addColumn('type', 'string', [
'notnull' => true, 'notnull' => true,
]); ]);
// Before // Before
$table->addColumn('before_file_exists', 'boolean', [ $table->addColumn('before_file_exists', 'boolean', [
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('before_path', 'string', [ $table->addColumn('before_path', 'string', [
'notnull' => false, 'notnull' => false,
'default' => '', 'default' => '',
'length' => 200, 'length' => 200,
]); ]);
$table->addColumn('before_size', 'integer', [ $table->addColumn('before_size', 'integer', [
'notnull' => false, 'notnull' => false,
'default' => 0 'default' => 0
]); ]);
// Current // Current
$table->addColumn('current_file_exists', 'boolean', [ $table->addColumn('current_file_exists', 'boolean', [
'notnull' => false, 'notnull' => false,
]); ]);
$table->addColumn('current_path', 'string', [ $table->addColumn('current_path', 'string', [
'notnull' => false, 'notnull' => false,
'default' => '', 'default' => '',
'length' => 200, 'length' => 200,
]); ]);
$table->addColumn('current_size', 'integer', [ $table->addColumn('current_size', 'integer', [
'notnull' => false, 'notnull' => false,
'default' => 0 'default' => 0
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['task_id'], 'taskid_index'); $table->addIndex(['task_id'], 'taskid_index');
$table->addForeignKeyConstraint($schema->getTable(self::TASKS_TABLE), ['task_id'], ['id'], ['onDelete' => 'CASCADE'], 'results_taskid_fk'); $table->addForeignKeyConstraint($schema->getTable(self::TASKS_TABLE), ['task_id'], ['id'], ['onDelete' => 'CASCADE'], 'results_taskid_fk');
} }
return $schema; return $schema;
} }
} }