<commit_before><?php
/**
 * FileDocComment
 * Blog install migration
 * Класс миграций для модуля Blog:
 *
 * @category YupeMigration
 * @package  YupeCMS
 * @author   YupeTeam <<EMAIL>>
 * @license  BSD https://raw.github.com/yupe/yupe/master/LICENSE
 * @link     http://yupe.ru
 **/

/**
 * Blog install migration
 * Класс миграций для модуля Blog:
 *
 * @category YupeMigration
 * @package  YupeCMS
 * @author   YupeTeam <<EMAIL>>
 * @license  BSD https://raw.github.com/yupe/yupe/master/LICENSE
 * @link     http://yupe.ru
 **/
class m000000_000000_blog_base extends CDbMigration
{
    /**
     * Функция настройки и создания таблицы:
     *
     * @return nothing
     **/
    public function safeUp()
    {
        $db = $this->getDbConnection();
        $options = Yii::app()->db->schema instanceof CMysqlSchema ? 'ENGINE=InnoDB DEFAULT CHARSET=utf8' : '';
        // blog
        $this->createTable(
            $db->tablePrefix . 'blog', array(
                'id' => 'pk',
                'name' => 'varchar(300) NOT NULL',
                'description' => "text",
                'icon' => "varchar(300) NOT NULL DEFAULT ''",
                'slug' => 'varchar(150) NOT NULL',
                'lang' => 'char(2) DEFAULT NULL',
                'type' => "tinyint(4) unsigned NOT NULL DEFAULT '1'",
                'status' => "tinyint(4) unsigned NOT NULL DEFAULT '1'",
                'create_user_id' => 'integer NOT NULL',
                'update_user_id' => 'integer NOT NULL',
                'create_date' => 'integer unsigned NOT NULL',
                'update_date' => 'integer unsigned NOT NULL',
            ), $options
        );

        $this->createIndex($db->tablePrefix . "blog_slug_uniq", $db->tablePrefix . 'blog', "slug,lang", true);
        $this->createIndex($db->tablePrefix . "blog_create_user_id", $db->tablePrefix . 'blog', "create_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_update_user_id", $db->tablePrefix . 'blog', "update_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_status", $db->tablePrefix . 'blog', "status", false);
        $this->createIndex($db->tablePrefix . "blog_type", $db->tablePrefix . 'blog', "type", false);
        $this->createIndex($db->tablePrefix . "blog_create_date", $db->tablePrefix . 'blog', "create_date", false);
        $this->createIndex($db->tablePrefix . "blog_update_date", $db->tablePrefix . 'blog', "update_date", false);
        $this->createIndex($db->tablePrefix . "blog_lang", $db->tablePrefix . 'blog', "lang", false);
        $this->createIndex($db->tablePrefix . "blog_slug", $db->tablePrefix . 'blog', "slug", false);

        $this->addForeignKey($db->tablePrefix . "blog_create_user_fk", $db->tablePrefix . 'blog', 'create_user_id', $db->tablePrefix . 'user', 'id', 'RESTRICT',  'NO ACTION');
        $this->addForeignKey($db->tablePrefix . "blog_update_user_fk", $db->tablePrefix . 'blog', 'update_user_id', $db->tablePrefix . 'user', 'id', 'RESTRICT', 'NO ACTION');


        // post
        $this->createTable(
            $db->tablePrefix . 'post', array(
                'id' => 'pk',
                'blog_id' => 'integer NOT NULL',
                'create_user_id' => 'integer NOT NULL',
                'update_user_id' => 'integer NOT NULL',
                'create_date' => 'integer NOT NULL',
                'update_date' => 'integer NOT NULL',
                'publish_date' => 'integer NOT NULL',
                'slug' => 'string NOT NULL',
                'lang' => 'char(2) DEFAULT NULL',
                'title' => 'string NOT NULL',
                'quote' => "varchar(300) NOT NULL DEFAULT ''",
                'content' => 'text NOT NULL',
                'link' => "string NOT NULL DEFAULT ''",
                'status' => "tinyint(4) unsigned NOT NULL DEFAULT '0'",
                'comment_status' => "tinyint(4) unsigned NOT NULL DEFAULT '1'",
                'access_type' => "tinyint(4) unsigned NOT NULL DEFAULT '1'",
                'keywords' => "string NOT NULL DEFAULT ''",
                'description' => "varchar(300) NOT NULL DEFAULT ''",
            ), $options
        );

        $this->createIndex($db->tablePrefix . "blog_post_slug_uniq", $db->tablePrefix . 'post', "slug,lang", true);
        $this->createIndex($db->tablePrefix . "blog_post_blog_id", $db->tablePrefix . 'post', "blog_id", false);
        $this->createIndex($db->tablePrefix . "blog_post_create_user_id", $db->tablePrefix . 'post', "create_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_post_update_user_id", $db->tablePrefix . 'post', "update_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_post_status", $db->tablePrefix . 'post', "status", false);
        $this->createIndex($db->tablePrefix . "blog_post_access_type", $db->tablePrefix . 'post', "access_type", false);
        $this->createIndex($db->tablePrefix . "blog_post_comment_status", $db->tablePrefix . 'post', "comment_status", false);
        $this->createIndex($db->tablePrefix . "blog_lang", $db->tablePrefix . 'post', "lang", false);
        $this->createIndex($db->tablePrefix . "blog_slug", $db->tablePrefix . 'post', "slug", false);

        $this->addForeignKey($db->tablePrefix . "blog_post_blog_fk", $db->tablePrefix . 'post', 'blog_id', $db->tablePrefix . 'blog', 'id', 'CASCADE', 'CASCADE');
        $this->addForeignKey($db->tablePrefix . "blog_post_create_user_fk", $db->tablePrefix . 'post', 'create_user_id', $db->tablePrefix . 'user', 'id', 'CASCADE', 'CASCADE');
        $this->addForeignKey($db->tablePrefix . "blog_post_update_user_fk", $db->tablePrefix . 'post', 'update_user_id', $db->tablePrefix . 'user', 'id', 'CASCADE', 'CASCADE');

        // user to blog
        $this->createTable(
            $db->tablePrefix . 'user_to_blog', array(
                'id' => 'pk',
                'user_id' => 'integer NOT NULL',
                'blog_id' => 'integer NOT NULL',
                'create_date' => 'integer NOT NULL',
                'update_date' => 'integer NOT NULL',
                'role' => "tinyint(3) unsigned NOT NULL DEFAULT '1'",
                'status' => "smallint(5) unsigned NOT NULL DEFAULT '1'",
                'note' => "varchar(300) NOT NULL DEFAULT ''",
            ), $options
        );<commit_msg>UPD: fixing m000000_000000_blog_base<commit_after><?php
/**
 * FileDocComment
 * Blog install migration
 * Класс миграций для модуля Blog:
 *
 * @category YupeMigration
 * @package  YupeCMS
 * @author   YupeTeam <<EMAIL>>
 * @license  BSD https://raw.github.com/yupe/yupe/master/LICENSE
 * @link     http://yupe.ru
 **/

/**
 * Blog install migration
 * Класс миграций для модуля Blog:
 *
 * @category YupeMigration
 * @package  YupeCMS
 * @author   YupeTeam <<EMAIL>>
 * @license  BSD https://raw.github.com/yupe/yupe/master/LICENSE
 * @link     http://yupe.ru
 **/
class m000000_000000_blog_base extends CDbMigration
{
    /**
     * Функция настройки и создания таблицы:
     *
     * @return nothing
     **/
    public function safeUp()
    {
        $db = $this->getDbConnection();
        $options = Yii::app()->db->schema instanceof CMysqlSchema ? 'ENGINE=InnoDB DEFAULT CHARSET=utf8' : '';
        // blog
        $this->createTable(
            $db->tablePrefix . 'blog', array(
                'id' => 'pk',
                'name' => 'varchar(300) NOT NULL',
                'description' => "text",
                'icon' => "varchar(300) NOT NULL DEFAULT ''",
                'slug' => 'varchar(150) NOT NULL',
                'lang' => 'char(2) DEFAULT NULL',
                'type' => "integer unsigned NOT NULL DEFAULT '1'",
                'status' => "integer unsigned NOT NULL DEFAULT '1'",
                'create_user_id' => 'integer NOT NULL',
                'update_user_id' => 'integer NOT NULL',
                'create_date' => 'integer unsigned NOT NULL',
                'update_date' => 'integer unsigned NOT NULL',
            ), $options
        );

        $this->createIndex($db->tablePrefix . "blog_slug_uniq", $db->tablePrefix . 'blog', "slug,lang", true);
        $this->createIndex($db->tablePrefix . "blog_create_user_id", $db->tablePrefix . 'blog', "create_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_update_user_id", $db->tablePrefix . 'blog', "update_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_status", $db->tablePrefix . 'blog', "status", false);
        $this->createIndex($db->tablePrefix . "blog_type", $db->tablePrefix . 'blog', "type", false);
        $this->createIndex($db->tablePrefix . "blog_create_date", $db->tablePrefix . 'blog', "create_date", false);
        $this->createIndex($db->tablePrefix . "blog_update_date", $db->tablePrefix . 'blog', "update_date", false);
        $this->createIndex($db->tablePrefix . "blog_lang", $db->tablePrefix . 'blog', "lang", false);
        $this->createIndex($db->tablePrefix . "blog_slug", $db->tablePrefix . 'blog', "slug", false);

        $this->addForeignKey($db->tablePrefix . "blog_create_user_fk", $db->tablePrefix . 'blog', 'create_user_id', $db->tablePrefix . 'user', 'id', 'RESTRICT',  'NO ACTION');
        $this->addForeignKey($db->tablePrefix . "blog_update_user_fk", $db->tablePrefix . 'blog', 'update_user_id', $db->tablePrefix . 'user', 'id', 'RESTRICT', 'NO ACTION');


        // post
        $this->createTable(
            $db->tablePrefix . 'post', array(
                'id' => 'pk',
                'blog_id' => 'integer NOT NULL',
                'create_user_id' => 'integer NOT NULL',
                'update_user_id' => 'integer NOT NULL',
                'create_date' => 'integer NOT NULL',
                'update_date' => 'integer NOT NULL',
                'publish_date' => 'integer NOT NULL',
                'slug' => 'string NOT NULL',
                'lang' => 'char(2) DEFAULT NULL',
                'title' => 'string NOT NULL',
                'quote' => "varchar(300) NOT NULL DEFAULT ''",
                'content' => 'text NOT NULL',
                'link' => "string NOT NULL DEFAULT ''",
                'status' => "integer unsigned NOT NULL DEFAULT '0'",
                'comment_status' => "integer unsigned NOT NULL DEFAULT '1'",
                'access_type' => "integer unsigned NOT NULL DEFAULT '1'",
                'keywords' => "string NOT NULL DEFAULT ''",
                'description' => "varchar(300) NOT NULL DEFAULT ''",
            ), $options
        );

        $this->createIndex($db->tablePrefix . "blog_post_slug_uniq", $db->tablePrefix . 'post', "slug,lang", true);
        $this->createIndex($db->tablePrefix . "blog_post_blog_id", $db->tablePrefix . 'post', "blog_id", false);
        $this->createIndex($db->tablePrefix . "blog_post_create_user_id", $db->tablePrefix . 'post', "create_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_post_update_user_id", $db->tablePrefix . 'post', "update_user_id", false);
        $this->createIndex($db->tablePrefix . "blog_post_status", $db->tablePrefix . 'post', "status", false);
        $this->createIndex($db->tablePrefix . "blog_post_access_type", $db->tablePrefix . 'post', "access_type", false);
        $this->createIndex($db->tablePrefix . "blog_post_comment_status", $db->tablePrefix . 'post', "comment_status", false);
        $this->createIndex($db->tablePrefix . "blog_lang", $db->tablePrefix . 'post', "lang", false);
        $this->createIndex($db->tablePrefix . "blog_slug", $db->tablePrefix . 'post', "slug", false);

        $this->addForeignKey($db->tablePrefix . "blog_post_blog_fk", $db->tablePrefix . 'post', 'blog_id', $db->tablePrefix . 'blog', 'id', 'CASCADE', 'CASCADE');
        $this->addForeignKey($db->tablePrefix . "blog_post_create_user_fk", $db->tablePrefix . 'post', 'create_user_id', $db->tablePrefix . 'user', 'id', 'CASCADE', 'CASCADE');
        $this->addForeignKey($db->tablePrefix . "blog_post_update_user_fk", $db->tablePrefix . 'post', 'update_user_id', $db->tablePrefix . 'user', 'id', 'CASCADE', 'CASCADE');

        // user to blog
        $this->createTable(
            $db->tablePrefix . 'user_to_blog', array(
                'id' => 'pk',
                'user_id' => 'integer NOT NULL',
                'blog_id' => 'integer NOT NULL',
                'create_date' => 'integer NOT NULL',
                'update_date' => 'integer NOT NULL',
                'role' => "integer unsigned NOT NULL DEFAULT '1'",
                'status' => "smallint(5) unsigned NOT NULL DEFAULT '1'",
                'note' => "varchar(300) NOT NULL DEFAULT ''",
            ), $options
        );
{'fraction_non_alphanumeric': 0.17468876377765444, 'fraction_numerical': 0.007929585282689715, 'mean_word_length': 2.5880512091038406, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 253, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3021592', 'n_tokens_mistral': 3992, 'n_tokens_neox': 3901, 'n_words': 838}