Skip to content

Commit

Permalink
Expand icon column of tags table to store extended emoji (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
vokomarov authored Nov 19, 2023
2 parents 715261d + 04e927d commit 5a0554a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
32 changes: 32 additions & 0 deletions app/migrations/20231119.084012_0_expand_tags_icon_column2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace App;

use Cycle\Migrations\Migration;

class ExpandTagsIconColumnMigration2 extends Migration
{
public function up(): void
{
$this->table('tags')
->alterColumn('icon', 'string', [
'nullable' => true,
'default' => null,
'size' => 10,
])
->update();
}

public function down(): void
{
$this->table('tags')
->alterColumn('icon', 'string', [
'nullable' => true,
'default' => null,
'size' => 4,
])
->update();
}
}
2 changes: 1 addition & 1 deletion app/src/Database/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Tag
#[ORM\Column(type: 'integer', name: 'user_id')]
public int $userId = 0;

#[ORM\Column(type: 'string(4)', nullable: true)]
#[ORM\Column(type: 'string(10)', nullable: true)]
public string|null $icon = null;

#[ORM\Column(type: 'string', nullable: true)]
Expand Down
2 changes: 1 addition & 1 deletion app/src/Request/Tag/CreateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function filterDefinition(): FilterDefinitionInterface
],
'icon' => [
['is_string'],
['string::range', 1, 7],
['string::range', 1, 10],
],
'color' => [
['is_string'],
Expand Down
2 changes: 1 addition & 1 deletion app/src/Request/Tag/UpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function filterDefinition(): FilterDefinitionInterface
],
'icon' => [
['is_string'],
['string::range', 1, 7]
['string::range', 1, 10]
],
'color' => [
['is_string'],
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Controller/Tags/TagsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function createValidationFailsDataProvider(): array
], ['name', 'icon', 'color']],
[[
'name' => 't',
'icon' => '12345678',
'icon' => '01234567891',
'color' => '#123abcg'
], ['name', 'icon', 'color']],
[[
Expand Down Expand Up @@ -288,7 +288,7 @@ public function updateValidationFailsDataProvider(): array
], ['name', 'icon', 'color']],
[[
'name' => 't',
'icon' => '12345678',
'icon' => '01234567891',
'color' => '#123abcg'
], ['name', 'icon', 'color']],
[[
Expand Down

0 comments on commit 5a0554a

Please sign in to comment.