<?php

use yii\db\Migration;

/**
 * Class m230314_094410_person
 */
class m230314_094410_person extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
		$sql = "CREATE TABLE `person` (
  `name` tinytext COLLATE utf8mb4_general_ci NOT NULL,
  `alias` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `jobtitle` text COLLATE utf8mb4_general_ci NOT NULL,
  `birthdate` date DEFAULT NULL,
  `description` text COLLATE utf8mb4_general_ci NOT NULL,
  `phone` tinytext COLLATE utf8mb4_general_ci NOT NULL,
  `email` tinytext COLLATE utf8mb4_general_ci NOT NULL,
  `id` int UNSIGNED NOT NULL,
  `show` enum('N','Y') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'N'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Эксперты и соавторы';";
		$this->execute($sql);
		$sql = "ALTER TABLE `person` ADD PRIMARY KEY (`id`),ADD UNIQUE KEY `url` (`alias`); ALTER TABLE `person` ADD FULLTEXT KEY `search` (`name`); COMMIT;";
		$this->execute($sql);
		$sql = "ALTER TABLE `person` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=0; COMMIT; COMMIT;";
		$this->execute($sql);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m230314_094410_person cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m230314_094410_person cannot be reverted.\n";

        return false;
    }
    */
}
