@@ -33,66 +33,66 @@ |
||
33 | 33 | use OCP\Migration\SimpleMigrationStep; |
34 | 34 | |
35 | 35 | class Version24000Date20211222112246 extends SimpleMigrationStep { |
36 | - private const TABLE_NAME = 'reactions'; |
|
36 | + private const TABLE_NAME = 'reactions'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * @return null|ISchemaWrapper |
|
43 | - */ |
|
44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
45 | - /** @var ISchemaWrapper $schema */ |
|
46 | - $schema = $schemaClosure(); |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * @return null|ISchemaWrapper |
|
43 | + */ |
|
44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
45 | + /** @var ISchemaWrapper $schema */ |
|
46 | + $schema = $schemaClosure(); |
|
47 | 47 | |
48 | - $action = false; |
|
49 | - $comments = $schema->getTable('comments'); |
|
50 | - if (!$comments->hasColumn('reactions')) { |
|
51 | - $comments->addColumn('reactions', Types::STRING, [ |
|
52 | - 'notnull' => false, |
|
53 | - 'length' => 4000, |
|
54 | - ]); |
|
55 | - $action = true; |
|
56 | - } |
|
48 | + $action = false; |
|
49 | + $comments = $schema->getTable('comments'); |
|
50 | + if (!$comments->hasColumn('reactions')) { |
|
51 | + $comments->addColumn('reactions', Types::STRING, [ |
|
52 | + 'notnull' => false, |
|
53 | + 'length' => 4000, |
|
54 | + ]); |
|
55 | + $action = true; |
|
56 | + } |
|
57 | 57 | |
58 | - if (!$schema->hasTable(self::TABLE_NAME)) { |
|
59 | - $table = $schema->createTable(self::TABLE_NAME); |
|
60 | - $table->addColumn('id', Types::BIGINT, [ |
|
61 | - 'autoincrement' => true, |
|
62 | - 'notnull' => true, |
|
63 | - 'length' => 11, |
|
64 | - 'unsigned' => true, |
|
65 | - ]); |
|
66 | - $table->addColumn('parent_id', Types::BIGINT, [ |
|
67 | - 'notnull' => true, |
|
68 | - 'length' => 11, |
|
69 | - 'unsigned' => true, |
|
70 | - ]); |
|
71 | - $table->addColumn('message_id', Types::BIGINT, [ |
|
72 | - 'notnull' => true, |
|
73 | - 'length' => 11, |
|
74 | - 'unsigned' => true, |
|
75 | - ]); |
|
76 | - $table->addColumn('actor_type', Types::STRING, [ |
|
77 | - 'notnull' => true, |
|
78 | - 'length' => 64, |
|
79 | - 'default' => '', |
|
80 | - ]); |
|
81 | - $table->addColumn('actor_id', Types::STRING, [ |
|
82 | - 'notnull' => true, |
|
83 | - 'length' => 64, |
|
84 | - 'default' => '', |
|
85 | - ]); |
|
86 | - $table->addColumn('reaction', Types::STRING, [ |
|
87 | - 'notnull' => true, |
|
88 | - 'length' => 32, |
|
89 | - ]); |
|
90 | - $table->setPrimaryKey(['id']); |
|
91 | - $table->addIndex(['reaction'], 'comment_reaction'); |
|
92 | - $table->addIndex(['parent_id'], 'comment_reaction_parent_id'); |
|
93 | - $table->addUniqueIndex(['parent_id', 'actor_type', 'actor_id', 'reaction'], 'comment_reaction_unique'); |
|
94 | - $action = true; |
|
95 | - } |
|
96 | - return $action ? $schema : null; |
|
97 | - } |
|
58 | + if (!$schema->hasTable(self::TABLE_NAME)) { |
|
59 | + $table = $schema->createTable(self::TABLE_NAME); |
|
60 | + $table->addColumn('id', Types::BIGINT, [ |
|
61 | + 'autoincrement' => true, |
|
62 | + 'notnull' => true, |
|
63 | + 'length' => 11, |
|
64 | + 'unsigned' => true, |
|
65 | + ]); |
|
66 | + $table->addColumn('parent_id', Types::BIGINT, [ |
|
67 | + 'notnull' => true, |
|
68 | + 'length' => 11, |
|
69 | + 'unsigned' => true, |
|
70 | + ]); |
|
71 | + $table->addColumn('message_id', Types::BIGINT, [ |
|
72 | + 'notnull' => true, |
|
73 | + 'length' => 11, |
|
74 | + 'unsigned' => true, |
|
75 | + ]); |
|
76 | + $table->addColumn('actor_type', Types::STRING, [ |
|
77 | + 'notnull' => true, |
|
78 | + 'length' => 64, |
|
79 | + 'default' => '', |
|
80 | + ]); |
|
81 | + $table->addColumn('actor_id', Types::STRING, [ |
|
82 | + 'notnull' => true, |
|
83 | + 'length' => 64, |
|
84 | + 'default' => '', |
|
85 | + ]); |
|
86 | + $table->addColumn('reaction', Types::STRING, [ |
|
87 | + 'notnull' => true, |
|
88 | + 'length' => 32, |
|
89 | + ]); |
|
90 | + $table->setPrimaryKey(['id']); |
|
91 | + $table->addIndex(['reaction'], 'comment_reaction'); |
|
92 | + $table->addIndex(['parent_id'], 'comment_reaction_parent_id'); |
|
93 | + $table->addUniqueIndex(['parent_id', 'actor_type', 'actor_id', 'reaction'], 'comment_reaction_unique'); |
|
94 | + $action = true; |
|
95 | + } |
|
96 | + return $action ? $schema : null; |
|
97 | + } |
|
98 | 98 | } |