1 | <?php |
||||
2 | |||||
3 | class m161228_100819_init extends \yii\db\Migration |
||||
4 | { |
||||
5 | use \carono\yii2migrate\traits\MigrationTrait; |
||||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
6 | |||||
7 | public $tableName = '{{%file_upload}}'; |
||||
8 | |||||
9 | public function newTables() |
||||
10 | { |
||||
11 | return [ |
||||
12 | $this->tableName => [ |
||||
13 | 'id' => $this->primaryKey(), |
||||
14 | 'uid' => $this->string(32)->unique()->comment('Уникальный идентификатор, используется для содания директорий хранения'), |
||||
15 | 'user_id' => $this->integer()->comment('Текущий пользователь, который сохраняет файл'), |
||||
16 | 'name' => $this->string()->comment('Имя файла, без расширения'), |
||||
17 | 'extension' => $this->string()->comment('Расширение'), |
||||
18 | 'folder' => $this->string()->comment('Папка, где хранится файл, можно использовать @алиасы'), |
||||
19 | 'mime_type' => $this->string()->comment('Mime Type по содержимому файла'), |
||||
20 | 'size' => $this->integer()->comment('Размер файла'), |
||||
21 | 'data' => $this->text()->comment('Произвольные данные'), |
||||
22 | 'session' => $this->string()->comment('Сессия текущего пользователя'), |
||||
23 | 'md5' => $this->string(32)->comment('MD5 по содержимому файла'), |
||||
24 | 'slug' => $this->string()->comment('Произвольный слаг'), |
||||
25 | 'is_active' => $this->boolean()->notNull()->defaultValue(true), |
||||
26 | 'is_exist' => $this->boolean()->notNull()->defaultValue(true)->comment('Существование реального файла'), |
||||
27 | 'binary' => $this->binary()->comment('Файл хранится в базе (на данный момент не используется)'), |
||||
28 | 'created_at' => $this->dateTime()->comment('Дата создания'), |
||||
29 | 'updated_at' => $this->dateTime()->comment('Дата обновления') |
||||
30 | ] |
||||
31 | ]; |
||||
32 | } |
||||
33 | |||||
34 | public function newIndex() |
||||
35 | { |
||||
36 | return [ |
||||
37 | [$this->tableName, ['is_active', 'is_exist']], |
||||
38 | [$this->tableName, 'slug'], |
||||
39 | ]; |
||||
40 | } |
||||
41 | |||||
42 | public function safeUp() |
||||
43 | { |
||||
44 | if ($this->db->driverName === 'mysql') { |
||||
45 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||||
46 | } else { |
||||
47 | $tableOptions = null; |
||||
48 | } |
||||
49 | $this->upNewTables([], $tableOptions); |
||||
0 ignored issues
–
show
It seems like
$tableOptions can also be of type string ; however, parameter $tableOptions of m161228_100819_init::upNewTables() does only seem to accept null , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
50 | $this->upNewIndex(); |
||||
51 | } |
||||
52 | |||||
53 | public function safeDown() |
||||
54 | { |
||||
55 | $this->downNewTables(); |
||||
56 | } |
||||
57 | } |
||||
58 |