adding forgotten files
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%questionnaire_category}}`.
|
||||
*/
|
||||
class m211018_080043_create_questionnaire_category_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%questionnaire_category}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'title' => $this->string(255)->notNull(),
|
||||
'status' => $this->integer(1),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%questionnaire_category}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%questionnaire}}`.
|
||||
*/
|
||||
class m211018_080608_create_questionnaire_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%questionnaire}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'category_id' => $this->integer(),
|
||||
'title' => $this->string(255),
|
||||
'status' => $this->integer(1),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
'time_limit' => $this->integer(),
|
||||
]);
|
||||
|
||||
$this->addForeignKey('category', 'questionnaire', 'category_id', 'questionnaire_category', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('category', 'questionnaire');
|
||||
$this->dropTable('{{%questionnaire}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%question_type}}`.
|
||||
*/
|
||||
class m211018_081700_create_question_type_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%question_type}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'question_type' => $this->string(255),
|
||||
'slug' => $this->string(255),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%question_type}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m211020_132810_add_default_question_types
|
||||
*/
|
||||
class m211020_132810_add_default_question_types extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
Yii::$app->db->createCommand()->batchInsert('question_type', ['question_type', 'slug'], [
|
||||
['Открытый вопрос', 'otkrytyj-vopros'],
|
||||
['Один правильный ответ', 'odin-pravilnyj-otvet'],
|
||||
['Несколько вариантов ответа', 'neskolko-variantov-otveta'],
|
||||
['Истина - ложь', 'istina-loz'],
|
||||
['Парное соответствие', 'parnoe-sootvetstvie'],
|
||||
['Заполнить пропуски', 'zapolnit-propuski'],
|
||||
])->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
Yii::$app->db->createCommand()->delete('question_type',
|
||||
[
|
||||
'in', 'question_type', [
|
||||
'Открытый вопрос',
|
||||
'Один правильный ответ',
|
||||
'Несколько вариантов ответа',
|
||||
'Истина - ложь',
|
||||
'Парное соответствие',
|
||||
'Заполнить пропуски'
|
||||
]
|
||||
])->execute();
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m211020_132810_add_default_question_types cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
43
console/migrations/m211020_132952_create_question_table.php
Normal file
43
console/migrations/m211020_132952_create_question_table.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%question}}`.
|
||||
*/
|
||||
class m211020_132952_create_question_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%question}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'question_type_id' => $this->integer(),
|
||||
'questionnaire_id' => $this->integer(),
|
||||
'question_body' => $this->string(255),
|
||||
'question_priority' => $this->integer(),
|
||||
'next_question' => $this->integer(),
|
||||
'status' => $this->integer(1),
|
||||
'score' => $this->integer(),
|
||||
'time_limit' => $this->integer(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
]);
|
||||
|
||||
$this->addForeignKey('question_type', 'question', 'question_type_id', 'question_type', 'id');
|
||||
$this->addForeignKey('questionnaire', 'question', 'questionnaire_id', 'questionnaire', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('question_type', 'question');
|
||||
$this->dropForeignKey('questionnaire', 'question');
|
||||
|
||||
$this->dropTable('{{%question}}');
|
||||
}
|
||||
}
|
36
console/migrations/m211020_133102_create_answer_table.php
Normal file
36
console/migrations/m211020_133102_create_answer_table.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%answer}}`.
|
||||
*/
|
||||
class m211020_133102_create_answer_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%answer}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'question_id' => $this->integer(),
|
||||
'answer_body' => $this->string(255)->notNull(),
|
||||
'answer_flag' => $this->integer(1),
|
||||
'status' => $this->integer(1),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
]);
|
||||
|
||||
$this->addForeignKey('answer_question', 'answer', 'question_id', 'question', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('answer_question', 'answer');
|
||||
$this->dropTable('{{%answer}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%user_questionnaire}}`.
|
||||
*/
|
||||
class m211020_133147_create_user_questionnaire_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%user_questionnaire}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'questionnaire_id' => $this->integer(),
|
||||
'user_id' => $this->integer(),
|
||||
'uuid' => $this->string(36)->unique(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
'score' => $this->integer(),
|
||||
'status' => $this->integer(),
|
||||
|
||||
|
||||
]);
|
||||
|
||||
$this->addForeignKey('questionnaire_user', 'user_questionnaire', 'questionnaire_id', 'questionnaire', 'id');
|
||||
$this->addForeignKey('user_questionnaire', 'user_questionnaire', 'user_id', 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('questionnaire_user', 'user_questionnaire');
|
||||
$this->dropForeignKey('user_questionnaire', 'user_questionnaire');
|
||||
|
||||
$this->dropTable('{{%user_questionnaire}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%user_response}}`.
|
||||
*/
|
||||
class m211020_133240_create_user_response_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%user_response}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'user_id' => $this->integer(),
|
||||
'question_id' => $this->integer(),
|
||||
'response_body' => $this->string(),
|
||||
'created_at' => $this->dateTime(),
|
||||
'updated_at' => $this->dateTime(),
|
||||
'answer_flag' => $this->double(),
|
||||
'user_questionnaire_id' => $this->integer(),
|
||||
]);
|
||||
|
||||
$this->addForeignKey('user_response', 'user_response', 'user_id', 'user', 'id');
|
||||
$this->addForeignKey('question_response', 'user_response', 'question_id', 'question', 'id');
|
||||
$this->addForeignKey(
|
||||
'questionnaire_response',
|
||||
'user_response',
|
||||
'user_questionnaire_id',
|
||||
'user_questionnaire',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('user_response', 'user_response');
|
||||
$this->dropForeignKey('question_response', 'user_response');
|
||||
$this->dropForeignKey('questionnaire_response', 'user_response');
|
||||
|
||||
$this->dropTable('{{%user_response}}');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user