<commit_before><?php

use common\modules\lead\Module;
use console\base\Migration;
use yii\db\ActiveRecord;

/**
 * Class m220113_131816_lead_source-dialer_phone
 */
class m220211_120416_lead_dialer extends Migration {

	/**
	 * {@inheritdoc}
	 */
	public function safeUp() {
		$this->addColumn('{{%lead_status}}', 'not_for_dialer', $this->boolean()->defaultValue(1));

		$this->createTable('{{%lead_dialer_type}}', [
			'id' => $this->primaryKey(),
			'name' => $this->string()->notNull()->unique(),
			'status' => $this->smallInteger()->notNull(),
			'user_id' => $this->integer()->notNull(),
		]);
		/** @var ActiveRecord $userClass */
		$userClass = Module::userClass();
		$this->addForeignKey(
			'{{%lead_dialer_type_user}}',
			'{{%lead_dialer_type}}',
			'user_id',
			$userClass::tableName(),
			'id',
			'CASCADE',
			'CASCADE'
		);

		$this->createTable('{{%lead_dialer}}', [
			'id' => $this->primaryKey(),
			'lead_id' => $this->integer()->notNull(),
			'type_id' => $this->integer()->notNull(),
			'priority' => $this->smallInteger(),
			'created_at' => $this->timestamp()->notNull(),
			'updated_at' => $this->timestamp()->notNull(),
			'status' => $this->smallInteger()->notNull(),
			'last_at' => $this->timestamp(),
			'dialer_config' => $this->json(),
		]);

		$this->addForeignKey(
			'{{%fk_lead_dialer_lead}}',
			'{{%lead_dialer}}',
			'lead_id',
			'{{%lead}}',
			'id',
			'CASCADE',
			'CASCADE'
		);

		$this->addForeignKey(
			'{{%fk_lead_dialer_type}}',
			'{{%lead_dialer}}',
			'type_id',
			'{{%lead_dialer_type}}',
			'id',
			'CASCADE',
			'CASCADE'
		);
	}

	/**<commit_msg>feat: lead dialer dates columns as DateTime.<commit_after><?php

use common\modules\lead\Module;
use console\base\Migration;
use yii\db\ActiveRecord;

/**
 * Class m220113_131816_lead_source-dialer_phone
 */
class m220211_120416_lead_dialer extends Migration {

	/**
	 * {@inheritdoc}
	 */
	public function safeUp() {
		$this->addColumn('{{%lead_status}}', 'not_for_dialer', $this->boolean()->defaultValue(1));

		$this->createTable('{{%lead_dialer_type}}', [
			'id' => $this->primaryKey(),
			'name' => $this->string()->notNull()->unique(),
			'status' => $this->smallInteger()->notNull(),
			'user_id' => $this->integer()->notNull(),
		]);
		/** @var ActiveRecord $userClass */
		$userClass = Module::userClass();
		$this->addForeignKey(
			'{{%lead_dialer_type_user}}',
			'{{%lead_dialer_type}}',
			'user_id',
			$userClass::tableName(),
			'id',
			'CASCADE',
			'CASCADE'
		);

		$this->createTable('{{%lead_dialer}}', [
			'id' => $this->primaryKey(),
			'lead_id' => $this->integer()->notNull(),
			'type_id' => $this->integer()->notNull(),
			'priority' => $this->smallInteger(),
			'created_at' => $this->dateTime()->notNull(),
			'updated_at' => $this->dateTime()->notNull(),
			'status' => $this->smallInteger()->notNull(),
			'last_at' => $this->dateTime()->null(),
			'dialer_config' => $this->json(),
		]);

		$this->addForeignKey(
			'{{%fk_lead_dialer_lead}}',
			'{{%lead_dialer}}',
			'lead_id',
			'{{%lead}}',
			'id',
			'CASCADE',
			'CASCADE'
		);

		$this->addForeignKey(
			'{{%fk_lead_dialer_type}}',
			'{{%lead_dialer}}',
			'type_id',
			'{{%lead_dialer_type}}',
			'id',
			'CASCADE',
			'CASCADE'
		);
	}

	/**
{'fraction_non_alphanumeric': 0.24661746617466174, 'fraction_numerical': 0.015375153751537515, 'mean_word_length': 4.341543513957307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, 'https://': 0, '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': '4036315', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1255, 'n_words': 160}