Skip to content

Commit

Permalink
fix(migration-attributes): psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jul 29, 2024
1 parent b3e1b83 commit 55a5d8e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 14 deletions.
28 changes: 14 additions & 14 deletions apps/testing/lib/Migration/Version30000Date20240102030405.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Testing\Migration;

use Closure;
Expand All @@ -21,19 +21,19 @@
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

#[DropTable('old_table')]
#[CreateTable('new_table', description: 'Table is used to store things, but also to get more things', notes: ['this is a notice', 'and another one, if really needed'])]
#[AddColumn('my_table')]
#[AddColumn('my_table', 'another_field')]
#[AddColumn('other_table', 'last_one', ColumnType::DATE)]
#[AddIndex('my_table')]
#[AddIndex('my_table', IndexType::PRIMARY)]
#[DropColumn('other_table')]
#[DropColumn('other_table', 'old_column', description: 'field is not used anymore and replaced by \'last_one\'')]
#[DropIndex('other_table')]
#[ModifyColumn('other_table')]
#[ModifyColumn('other_table', 'this_field')]
#[ModifyColumn('other_table', 'this_field', ColumnType::BIGINT)]
#[DropTable(table: 'old_table')]
#[CreateTable(table: 'new_table', description: 'Table is used to store things, but also to get more things', notes: ['this is a notice', 'and another one, if really needed'])]
#[AddColumn(table: 'my_table')]
#[AddColumn(table: 'my_table', name: 'another_field')]
#[AddColumn(table: 'other_table', name: 'last_one', type: ColumnType::DATE)]
#[AddIndex(table: 'my_table')]
#[AddIndex(table: 'my_table', type: IndexType::PRIMARY)]
#[DropColumn(table: 'other_table')]
#[DropColumn(table: 'other_table', name: 'old_column', description: 'field is not used anymore and replaced by \'last_one\'')]
#[DropIndex(table: 'other_table')]
#[ModifyColumn(table: 'other_table')]
#[ModifyColumn(table: 'other_table', name: 'this_field')]
#[ModifyColumn(table: 'other_table', name: 'this_field', type: ColumnType::BIGINT)]
class Version30000Date20240102030405 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
return null;
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Migration/Attributes/ColumnMigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
* @since 30.0.0
*/
class ColumnMigrationAttribute extends MigrationAttribute implements JsonSerializable {
/**
* @param string $table name of the database table
* @param string $name name of the column
* @param ColumnType|null $type type of the column
* @param string $description description of the migration
* @param array $notes notes about the migration/column
* @since 30.0.0
*/
public function __construct(
string $table,
private string $name = '',
Expand Down
4 changes: 4 additions & 0 deletions lib/public/Migration/Attributes/GenericMigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* @since 30.0.0
*/
class GenericMigrationAttribute extends MigrationAttribute implements JsonSerializable {
/**
* @param array $details
* @since 30.0.0
*/
public function __construct(
private readonly array $details = []
) {
Expand Down
7 changes: 7 additions & 0 deletions lib/public/Migration/Attributes/IndexMigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
* @since 30.0.0
*/
class IndexMigrationAttribute extends MigrationAttribute implements JsonSerializable {
/**
* @param string $table name of the database table
* @param IndexType|null $type type of the index
* @param string $description description of the migration
* @param array $notes notes abour the migration/index
* @since 30.0.0
*/
public function __construct(
string $table,
private ?IndexType $type = null,
Expand Down
6 changes: 6 additions & 0 deletions lib/public/Migration/Attributes/MigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
* @since 30.0.0
*/
class MigrationAttribute implements JsonSerializable {
/**
* @param string $table name of the database table
* @param string $description description of the migration
* @param array $notes notes about the migration
* @since 30.0.0
*/
public function __construct(
private string $table,
private string $description = '',
Expand Down
7 changes: 7 additions & 0 deletions lib/public/Migration/Attributes/TableMigrationAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
* @since 30.0.0
*/
class TableMigrationAttribute extends MigrationAttribute implements JsonSerializable {
/**
* @param string $table name of the database table
* @param array $columns list of columns
* @param string $description description of the migration
* @param array $notes notes about the migration/table
* @since 30.0.0
*/
public function __construct(
string $table,
private array $columns = [],
Expand Down

0 comments on commit 55a5d8e

Please sign in to comment.