69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
use yii\db\Migration;
|
|
|
|
/**
|
|
* Class m220213_134539_add_table_mobile_device
|
|
*/
|
|
class m220213_134539_add_table_mobile_device extends Migration
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function safeUp()
|
|
{
|
|
$tableOptions = null;
|
|
if ($this->db->driverName === 'mysql') {
|
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
|
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
|
}
|
|
|
|
$this->createTable('{{%mobile_device}}', [
|
|
'id' => $this->primaryKey(),
|
|
'id_card' => $this->integer(11),
|
|
'status' => $this->string(20),
|
|
'device_identifier' => $this->string(255),
|
|
'activated_at' => $this->dateTime(),
|
|
'created_at' => $this->dateTime()->notNull(),
|
|
'updated_at' => $this->dateTime()->notNull(),
|
|
], $tableOptions);
|
|
|
|
$this->createTable('{{%virtual_key}}', [
|
|
'id' => $this->primaryKey(),
|
|
'id_card' => $this->integer(11),
|
|
'id_key' => $this->integer(11),
|
|
'valid_until' => $this->dateTime()->notNull(),
|
|
'direction_in_at' => $this->dateTime(),
|
|
'direction_out_at' => $this->dateTime(),
|
|
'created_at' => $this->dateTime()->notNull(),
|
|
'updated_at' => $this->dateTime()->notNull(),
|
|
], $tableOptions);
|
|
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function safeDown()
|
|
{
|
|
echo "m220213_134539_add_table_mobile_device cannot be reverted.\n";
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
// Use up()/down() to run migration code without a transaction.
|
|
public function up()
|
|
{
|
|
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
echo "m220213_134539_add_table_mobile_device cannot be reverted.\n";
|
|
|
|
return false;
|
|
}
|
|
*/
|
|
}
|