Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
SetupVersion_0001 | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
migrateIOSystem | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
migrateDatabase | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Setup\Versions; |
6 | |
7 | use PeServer\App\Models\Setup\DatabaseSetupArgument; |
8 | use PeServer\App\Models\Setup\IOSetupArgument; |
9 | |
10 | /** |
11 | * @SuppressWarnings(PHPMD.CamelCaseClassName) |
12 | */ |
13 | #[Version(1)] |
14 | class SetupVersion_0001 extends SetupVersionBase //phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps |
15 | { |
16 | #region SetupVersionBase |
17 | |
18 | protected function migrateIOSystem(IOSetupArgument $argument): void |
19 | { |
20 | //NOP |
21 | } |
22 | |
23 | protected function migrateDatabase(DatabaseSetupArgument $argument): void |
24 | { |
25 | $statements = <<<SQL |
26 | |
27 | drop table |
28 | [access_keys] |
29 | ; |
30 | |
31 | create table |
32 | [api_keys] |
33 | ( |
34 | [api_key] text not null, -- APIキー |
35 | [user_id] text not null, -- ユーザーID |
36 | [secret_key] text not null, -- シークレットキー |
37 | [created_timestamp] datetime not null, -- 作成日 |
38 | primary key([api_key]), |
39 | unique([api_key], [user_id]), |
40 | foreign key ([user_id]) references users([user_id]) |
41 | ) |
42 | ; |
43 | |
44 | SQL; |
45 | |
46 | foreach ($this->splitStatements($statements) as $statement) { |
47 | $argument->default->execute($statement); |
48 | } |
49 | } |
50 | |
51 | #endregion |
52 | } |