first commit

This commit is contained in:
king199025
2018-10-11 11:15:09 +03:00
commit 9e8e98c379
230 changed files with 12117 additions and 0 deletions

View File

@ -0,0 +1,33 @@
<?php
use yii\db\Migration;
class m130524_201442_init extends Migration
{
public function up()
{
$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('{{%user}}', [
'id' => $this->primaryKey(),
'username' => $this->string()->notNull()->unique(),
'auth_key' => $this->string(32)->notNull(),
'password_hash' => $this->string()->notNull(),
'password_reset_token' => $this->string()->unique(),
'email' => $this->string()->notNull()->unique(),
'status' => $this->smallInteger()->notNull()->defaultValue(10),
'created_at' => $this->integer()->notNull(),
'updated_at' => $this->integer()->notNull(),
], $tableOptions);
}
public function down()
{
$this->dropTable('{{%user}}');
}
}

View File

@ -0,0 +1,44 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `status`.
*/
class m181003_070416_create_status_table 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('status', [
'id' => $this->primaryKey(),
'name' => $this->string(100)->notNull(),
], $tableOptions);
$this->insert('status',
[
'name' => 'Активный',
]);
$this->insert('status',
[
'name' => 'Уволен',
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('status');
}
}

View File

@ -0,0 +1,54 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `user_card`.
*/
class m181003_070636_create_user_card_table 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('user_card', [
'id' => $this->primaryKey(),
'fio' => $this->string(255)->notNull(),
'passport' => $this->string(255),
'photo' => $this->string(255),
'email' => $this->string(255),
'gender' => $this->tinyInteger(1),
'dob' => $this->date(),
'status' => $this->integer(11)->notNull(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
], $tableOptions);
$this->addForeignKey(
'user_card_ibfk_status',
'user_card',
'status',
'status',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('user_card_ibfk_status', 'user_card');
$this->dropTable('user_card');
}
}

View File

@ -0,0 +1,34 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `additional_fields`.
*/
class m181003_082730_create_additional_fields_table 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('additional_fields', [
'id' => $this->primaryKey(),
'name' => $this->string(100)->notNull(),
], $tableOptions);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('additional_fields');
}
}

View File

@ -0,0 +1,59 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `fields_value`.
*/
class m181003_092319_create_fields_value_table 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('fields_value', [
'id' => $this->primaryKey(),
'card_id' => $this->integer(11)->notNull(),
'field_id' => $this->integer(11)->notNull(),
'value' => $this->string(255)->notNull(),
], $tableOptions);
$this->addForeignKey(
'fields_value_ibfk_additional_fields',
'fields_value',
'field_id',
'additional_fields',
'id',
'RESTRICT',
'CASCADE'
);
$this->addForeignKey(
'fields_value_ibfk_user_card',
'fields_value',
'card_id',
'user_card',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('fields_value_ibfk_additional_fields','fields_value');
$this->dropForeignKey('fields_value_ibfk_user_card','fields_value');
$this->dropTable('fields_value');
}
}

View File

@ -0,0 +1,40 @@
<?php
use yii\db\Migration;
/**
* Class m181004_095927_add_column_resume_to_user_card_table
*/
class m181004_095927_add_column_resume_to_user_card_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user_card', 'resume', $this->string(255));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('user_card', 'resume');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m181004_095927_add_column_resume_to_user_card_table cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,40 @@
<?php
use yii\db\Migration;
/**
* Class m181004_102703_add_column_order_to_fields_value_table
*/
class m181004_102703_add_column_order_to_fields_value_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('fields_value', 'order', $this->integer(11));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('fields_value', 'order');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m181004_102703_add_column_order_to_fields_value_table cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,47 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `use_status`.
*/
class m181005_114117_create_use_status_table 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('use_status', [
'id' => $this->primaryKey(),
'status_id' => $this->integer(11)->notNull(),
'use' => $this->integer(11)->notNull(),
], $tableOptions);
$this->addForeignKey(
'use_status_ibfk_status',
'use_status',
'status_id',
'status',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('use_status_ibfk_status', 'use_status');
$this->dropTable('use_status');
}
}

View File

@ -0,0 +1,46 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `use_field`.
*/
class m181008_065248_create_use_field_table 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('use_field', [
'id' => $this->primaryKey(),
'field_id' => $this->integer(11)->notNull(),
'use' => $this->integer(11)->notNull(),
], $tableOptions);
$this->addForeignKey(
'use_field_ibfk_additional_fields',
'use_field',
'field_id',
'additional_fields',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('use_field_ibfk_additional_fields', 'use_field');
$this->dropTable('use_field');
}
}

View File

@ -0,0 +1,37 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `project`.
*/
class m181008_090446_create_project_table 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('project', [
'id' => $this->primaryKey(),
'name' => $this->string(255)->notNull(),
'description' => $this->text(),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
], $tableOptions);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('project');
}
}

View File

@ -0,0 +1,53 @@
<?php
use yii\db\Migration;
/**
* Class m181008_095803_add_project_id_field_to_fields_value
*/
class m181008_095803_add_project_id_field_to_fields_value extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('fields_value', 'project_id', $this->integer(11));
$this->alterColumn('fields_value', 'card_id', $this->integer(11));
$this->addForeignKey(
'fields_value_ibfk_project',
'fields_value',
'project_id',
'project',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('fields_value_ibfk_project', 'fields_value');
$this->dropColumn('fields_value', 'project_id');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m181008_095803_add_project_id_field_to_fields_value cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,58 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `project_user`.
*/
class m181008_105959_create_project_user_table 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('project_user', [
'id' => $this->primaryKey(),
'card_id' => $this->integer(11)->notNull(),
'project_id' => $this->integer(11)->notNull(),
], $tableOptions);
$this->addForeignKey(
'project_user_ibfk_project',
'project_user',
'project_id',
'project',
'id',
'RESTRICT',
'CASCADE'
);
$this->addForeignKey(
'project_user_ibfk_user_card',
'project_user',
'card_id',
'user_card',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('project_user_ibfk_project', 'project_user');
$this->dropForeignKey('project_user_ibfk_user_card', 'project_user');
$this->dropTable('project_user');
}
}