mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-04 02:36:49 +07:00
Merge pull request #12074 from nextcloud/feat/46476/migration-attributes
migration attributes
This commit is contained in:
@@ -100,12 +100,9 @@ instance into your migration class like this:
|
||||
.. code-block:: php
|
||||
|
||||
class Version2404Date20220903071748 extends SimpleMigrationStep {
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $db;
|
||||
|
||||
public function __construct(IDBConnection $db) {
|
||||
$this->db = $db;
|
||||
public function __construct(
|
||||
private IDBConnection $db
|
||||
) {
|
||||
}
|
||||
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
@@ -114,6 +111,41 @@ instance into your migration class like this:
|
||||
}
|
||||
}
|
||||
|
||||
Migrations and Metadata
|
||||
-----------------------
|
||||
|
||||
Since 30, details about migrations are available to administrator as metadata can be attached to your migration class by adding specific PHP Attributes:
|
||||
|
||||
.. code-block:: php
|
||||
:emphasize-lines: 5-10
|
||||
|
||||
use OCP\Migration\Attributes\CreateTable;
|
||||
use OCP\Migration\Attributes\ColumnType;
|
||||
use OCP\Migration\Attributes\ModifyColumn;
|
||||
|
||||
#[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']
|
||||
)]
|
||||
#[ModifyColumn(table: 'other_table', name: 'this_field', type: ColumnType::BIGINT)]
|
||||
class Version30000Date20240729185117 extends SimpleMigrationStep {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
[...]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List of available Migration Attributes:
|
||||
|
||||
* ``\OCP\Migration\Attributes\AddColumn`` if your migration implies the creation of a new column
|
||||
* ``\OCP\Migration\Attributes\AddIndex`` if your migration adds a new index
|
||||
* ``\OCP\Migration\Attributes\CreateTable`` if your migration creates a new table
|
||||
* ``\OCP\Migration\Attributes\DropColumn`` if your migration drops a column
|
||||
* ``\OCP\Migration\Attributes\DropIndex`` if your migration drops an index
|
||||
* ``\OCP\Migration\Attributes\DropTable`` if your migration drops a table
|
||||
* ``\OCP\Migration\Attributes\ModifyColumn`` if your migration modifies a column
|
||||
|
||||
.. _migration_console_command:
|
||||
|
||||
Console commands
|
||||
|
||||
Reference in New Issue
Block a user