-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathVersion20240428215320.php
65 lines (56 loc) · 1.89 KB
/
Version20240428215320.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
// phpcs:ignoreFile
namespace DoctrineMigrations;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Override;
/**
* Change api_key table
*/
final class Version20240428215320 extends AbstractMigration
{
/**
* @noinspection PhpMissingParentCallCommonInspection
*/
#[Override]
public function getDescription(): string
{
return 'Add fields: token_hash, token_parameters, change token field inside api_key table.';
}
/**
* @noinspection PhpMissingParentCallCommonInspection
*/
#[Override]
public function isTransactional(): bool
{
return false;
}
/**
* {@inheritdoc}
*/
#[Override]
public function up(Schema $schema): void
{
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform,
'Migration can only be executed safely on \'mysql\'.'
);
$this->addSql('ALTER TABLE api_key ADD token_hash VARCHAR(255) DEFAULT NULL COMMENT \'Token hash (when encrypted)\' AFTER token, ADD token_parameters JSON DEFAULT NULL COMMENT \'Token decrypt parameters (when encrypted)\' AFTER token_hash, CHANGE token token VARCHAR(255) NOT NULL COMMENT \'Generated API key string for authentication\'');
}
/**
* @noinspection PhpMissingParentCallCommonInspection
*
* {@inheritdoc}
*/
#[Override]
public function down(Schema $schema): void
{
$this->abortIf(
!$this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform,
'Migration can only be executed safely on \'mysql\'.'
);
$this->addSql('ALTER TABLE api_key DROP token_hash, DROP token_parameters, CHANGE token token VARCHAR(40) NOT NULL COMMENT \'Generated API key string for authentication\'');
}
}