diff --git a/.github/workflows/phpunit-mariadb.yml b/.github/workflows/phpunit-mariadb.yml index 02082a5a..0b9dead1 100644 --- a/.github/workflows/phpunit-mariadb.yml +++ b/.github/workflows/phpunit-mariadb.yml @@ -74,7 +74,7 @@ jobs: matrix: php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }} server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }} - mariadb-versions: ['10.6', '10.11'] + mariadb-versions: ['10.6', '10.11', '11.8'] name: MariaDB ${{ matrix.mariadb-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} @@ -84,8 +84,8 @@ jobs: ports: - 4444:3306/tcp env: - MYSQL_ROOT_PASSWORD: rootpassword - options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5 + MARIADB_ROOT_PASSWORD: rootpassword + options: --health-cmd="mariadb-admin ping" --health-interval 5s --health-timeout 2s --health-retries 5 steps: - name: Set app env diff --git a/lib/Db/FaceDetection.php b/lib/Db/FaceDetection.php index abbceda5..fcd5e833 100644 --- a/lib/Db/FaceDetection.php +++ b/lib/Db/FaceDetection.php @@ -21,8 +21,6 @@ * @method float getY() * @method float getHeight() * @method float getWidth() - * @method float[] getVector() - * @method setVector(array $vector) * @method setX(float $x) * @method setY(float $y) * @method setHeight(float $height) @@ -30,7 +28,7 @@ * @method setClusterId(int|null $clusterId) * @method int|null getClusterId() * @method float getThreshold() - * @method setThreshold(float $threshold) + * @method setThreshold(float $threshold) */ class FaceDetection extends Entity { protected $fileId; @@ -39,17 +37,17 @@ class FaceDetection extends Entity { protected $y; protected $height; protected $width; - protected $vector; + protected $faceVector; protected $clusterId; protected $threshold; /** * @var string[] */ - public static $columns = ['id', 'user_id', 'file_id', 'x', 'y', 'height', 'width', 'vector', 'cluster_id', 'threshold']; + public static $columns = ['id', 'user_id', 'file_id', 'x', 'y', 'height', 'width', 'face_vector', 'cluster_id', 'threshold']; /** * @var string[] */ - public static $fields = ['id', 'userId', 'fileId', 'x', 'y', 'height', 'width', 'vector', 'clusterId', 'threshold']; + public static $fields = ['id', 'userId', 'fileId', 'x', 'y', 'height', 'width', 'faceVector', 'clusterId', 'threshold']; public function __construct() { // add types in constructor @@ -60,7 +58,7 @@ public function __construct() { $this->addType('y', 'float'); $this->addType('height', 'float'); $this->addType('width', 'float'); - $this->addType('vector', 'json'); + $this->addType('faceVector', 'json'); $this->addType('clusterId', 'integer'); $this->addType('threshold', 'float'); } @@ -68,11 +66,18 @@ public function __construct() { public function toArray(): array { $array = []; foreach (static::$fields as $field) { - if ($field === 'vector') { + if ($field === 'faceVector') { continue; } $array[$field] = $this->{$field}; } return $array; } + + public function getVector(): array { + return $this->getter('faceVector'); + } + public function setVector(array $vector): void { + $this->setter('faceVector', [$vector]); + } } diff --git a/lib/Migration/Version002002000Date20220614094721.php b/lib/Migration/Version002002000Date20220614094721.php index 17879ff4..0a902f81 100644 --- a/lib/Migration/Version002002000Date20220614094721.php +++ b/lib/Migration/Version002002000Date20220614094721.php @@ -65,7 +65,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table->addColumn('width', Types::FLOAT, [ 'notnull' => false, ]); - $table->addColumn('vector', Types::TEXT, [ + $table->addColumn('face_vector', Types::TEXT, [ 'notnull' => true, ]); $table->addColumn('cluster_id', 'bigint', [ diff --git a/lib/Migration/Version010000001Date20250727094721.php b/lib/Migration/Version010000001Date20250727094721.php new file mode 100644 index 00000000..5a264eca --- /dev/null +++ b/lib/Migration/Version010000001Date20250727094721.php @@ -0,0 +1,68 @@ +hasTable('recognize_face_detections')) { + $table = $schema->getTable('recognize_face_detections'); + if (!$table->hasColumn('face_vector')) { + $table->addColumn('face_vector', Types::TEXT, [ + 'notnull' => true, + ]); + return $schema; + } + } + return null; + } + + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if (!$schema->hasTable('recognize_face_detections')) { + return; + } + + $table = $schema->getTable('recognize_face_detections'); + $copyData = $table->hasColumn('face_vector') && $table->hasColumn('vector'); + if (!$copyData) { + return; + } + + $query = $this->db->getQueryBuilder(); + $query->update('recognize_face_detections') + ->set('face_vector', 'vector'); + $query->executeStatement(); + } +} diff --git a/lib/Migration/Version010000001Date20250727094821.php b/lib/Migration/Version010000001Date20250727094821.php new file mode 100644 index 00000000..591dfdd9 --- /dev/null +++ b/lib/Migration/Version010000001Date20250727094821.php @@ -0,0 +1,39 @@ +hasTable('recognize_face_detections')) { + $table = $schema->getTable('recognize_face_detections'); + if ($table->hasColumn('vector')) { + $table->dropColumn('vector'); + return $schema; + } + } + return null; + } +}