|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://dukt.net/videos/ |
|
4
|
|
|
* @copyright Copyright (c) Dukt |
|
5
|
|
|
* @license https://github.com/dukt/videos/blob/v2/LICENSE.md |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace dukt\videos\migrations; |
|
9
|
|
|
|
|
10
|
|
|
use Craft; |
|
11
|
|
|
use craft\db\Migration; |
|
12
|
|
|
use dukt\videos\models\Info; |
|
|
|
|
|
|
13
|
|
|
use dukt\videos\Plugin; |
|
14
|
|
|
|
|
15
|
|
|
class Install extends Migration |
|
16
|
|
|
{ |
|
17
|
|
|
// Public Properties |
|
18
|
|
|
// ========================================================================= |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var string The database driver to use |
|
22
|
|
|
*/ |
|
23
|
|
|
public $driver; |
|
24
|
|
|
|
|
25
|
|
|
// Public Methods |
|
26
|
|
|
// ========================================================================= |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* This method contains the logic to be executed when applying this migration. |
|
30
|
|
|
* This method differs from [[up()]] in that the DB logic implemented here will |
|
31
|
|
|
* be enclosed within a DB transaction. |
|
32
|
|
|
* Child classes may implement this method instead of [[up()]] if the DB logic |
|
33
|
|
|
* needs to be within a transaction. |
|
34
|
|
|
* |
|
35
|
|
|
* @return boolean return a false value to indicate the migration fails |
|
36
|
|
|
* and should not proceed further. All other return values mean the migration succeeds. |
|
37
|
|
|
*/ |
|
38
|
|
|
public function safeUp(): bool |
|
39
|
|
|
{ |
|
40
|
|
|
$this->driver = Craft::$app->getConfig()->getDb()->driver; |
|
41
|
|
|
$this->createTables(); |
|
42
|
|
|
$this->createIndexes(); |
|
43
|
|
|
$this->addForeignKeys(); |
|
44
|
|
|
$this->insertDefaultData(); |
|
45
|
|
|
|
|
46
|
|
|
return true; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* This method contains the logic to be executed when removing this migration. |
|
51
|
|
|
* This method differs from [[down()]] in that the DB logic implemented here will |
|
52
|
|
|
* be enclosed within a DB transaction. |
|
53
|
|
|
* Child classes may implement this method instead of [[down()]] if the DB logic |
|
54
|
|
|
* needs to be within a transaction. |
|
55
|
|
|
* |
|
56
|
|
|
* @return boolean return a false value to indicate the migration fails |
|
57
|
|
|
* and should not proceed further. All other return values mean the migration succeeds. |
|
58
|
|
|
*/ |
|
59
|
|
|
public function safeDown(): bool |
|
60
|
|
|
{ |
|
61
|
|
|
$this->driver = Craft::$app->getConfig()->getDb()->driver; |
|
62
|
|
|
$this->removeTables(); |
|
63
|
|
|
|
|
64
|
|
|
return true; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
// Protected Methods |
|
68
|
|
|
// ========================================================================= |
|
69
|
|
|
/** |
|
70
|
|
|
* Creates the tables needed for the Records used by the plugin |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function createTables(): void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->createTable( |
|
75
|
|
|
'{{%videos_tokens}}', |
|
76
|
|
|
[ |
|
77
|
|
|
'id' => $this->primaryKey(), |
|
78
|
|
|
'gateway' => $this->string()->notNull(), |
|
79
|
|
|
'accessToken' => $this->text(), |
|
80
|
|
|
|
|
81
|
|
|
'dateCreated' => $this->dateTime()->notNull(), |
|
82
|
|
|
'dateUpdated' => $this->dateTime()->notNull(), |
|
83
|
|
|
'uid' => $this->uid() |
|
84
|
|
|
] |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Creates the indexes needed for the Records used by the plugin |
|
90
|
|
|
*/ |
|
91
|
|
|
protected function createIndexes(): void |
|
92
|
|
|
{ |
|
93
|
|
|
$this->createIndex(null, '{{%videos_tokens}}', 'gateway', true); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Creates the foreign keys needed for the Records used by the plugin |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function addForeignKeys(): void |
|
100
|
|
|
{ |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Populates the DB with the default data. |
|
105
|
|
|
*/ |
|
106
|
|
|
protected function insertDefaultData(): void |
|
107
|
|
|
{ |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Removes the tables needed for the Records used by the plugin |
|
112
|
|
|
*/ |
|
113
|
|
|
protected function removeTables(): void |
|
114
|
|
|
{ |
|
115
|
|
|
$this->dropTable('{{%videos_tokens}}'); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths