create project

This commit is contained in:
2024-04-24 18:02:58 +03:00
commit 17df2ce6a9
276 changed files with 15932 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') {
// https://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,16 @@
<?php
use \yii\db\Migration;
class m190124_110200_add_verification_token_column_to_user_table extends Migration
{
public function up()
{
$this->addColumn('{{%user}}', 'verification_token', $this->string()->defaultValue(null));
}
public function down()
{
$this->dropColumn('{{%user}}', 'verification_token');
}
}

View File

@ -0,0 +1,33 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%company}}`.
*/
class m240110_152351_create_company_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%company}}', [
'id' => $this->primaryKey(),
'inn' => $this->string(255)->notNull(),
'name' => $this->string(255)->notNull(),
'address' => $this->string(255),
'created_at' => $this->dateTime(),
'updated_at' => $this->dateTime(),
'status' => $this->integer(1)->defaultValue(1)
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%company}}');
}
}

View File

@ -0,0 +1,52 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%addresses}}`.
*/
class m240110_153348_create_addresses_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%addresses}}', [
'id' => $this->primaryKey(),
'address' => $this->string(255)->notNull(),
'company_id' => $this->integer(11)->notNull(),
'name' => $this->string(255),
]);
$this->createIndex('idx-addresses-company_id', 'addresses', 'company_id');
$this->addForeignKey(
'fk-addresses-company_id',
'addresses',
'company_id',
'company',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey(
'fk-addresses-company_id',
'addresses'
);
// drops index for column `author_id`
$this->dropIndex(
'idx-addresses-company_id',
'addresses'
);
$this->dropTable('{{%addresses}}');
}
}

View File

@ -0,0 +1,55 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%product}}`.
*/
class m240110_154916_create_product_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%product}}', [
'id' => $this->primaryKey(),
'title' => $this->string(255)->notNull(),
'article' => $this->string(255)->notNull(),
'company_id' => $this->integer(11)->notNull(),
'type' => $this->integer(1)->defaultValue(1),
'price' => $this->integer(11)->defaultValue(0),
'status' => $this->integer(1)->defaultValue(1),
]);
$this->createIndex('idx-product-company_id', 'product', 'company_id');
$this->addForeignKey(
'fk-product-company_id',
'product',
'company_id',
'company',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey(
'fk-product-company_id',
'product'
);
// drops index for column `author_id`
$this->dropIndex(
'idx-product-company_id',
'product'
);
$this->dropTable('{{%product}}');
}
}

View File

@ -0,0 +1,75 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%check}}`.
*/
class m240110_155920_create_check_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%check}}', [
'id' => $this->primaryKey(),
'number' => $this->string(255)->notNull(),
'company_id' => $this->integer(11)->notNull(),
'addresses_id' => $this->integer(11)->notNull(),
'status' => $this->integer(1)->defaultValue(1),
]);
$this->createIndex('idx-check-company_id', 'check', 'company_id');
$this->addForeignKey(
'fk-check-company_id',
'check',
'company_id',
'company',
'id',
'CASCADE'
);
$this->createIndex('idx-check-addresses_id', 'check', 'addresses_id');
$this->addForeignKey(
'fk-check-addresses_id',
'check',
'addresses_id',
'addresses',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey(
'fk-check-company_id',
'check'
);
// drops index for column `author_id`
$this->dropIndex(
'idx-check-company_id',
'check'
);
$this->dropForeignKey(
'fk-check-addresses_id',
'check'
);
// drops index for column `author_id`
$this->dropIndex(
'idx-check-addresses_id',
'check'
);
$this->dropTable('{{%check}}');
}
}

View File

@ -0,0 +1,92 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%check_product}}`.
* Has foreign keys to the tables:
*
* - `{{%check}}`
* - `{{%product}}`
*/
class m240110_161944_create_junction_table_for_check_and_product_tables extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%check_product}}', [
'check_id' => $this->integer(11)->notNull(),
'product_id' => $this->integer(11)->notNull(),
'quantity' => $this->integer(11)->defaultValue(1),
'PRIMARY KEY(check_id, product_id)',
]);
// creates index for column `check_id`
$this->createIndex(
'{{%idx-check_product-check_id}}',
'{{%check_product}}',
'check_id'
);
// add foreign key for table `{{%check}}`
$this->addForeignKey(
'{{%fk-check_product-check_id}}',
'{{%check_product}}',
'check_id',
'{{%check}}',
'id',
'CASCADE'
);
// creates index for column `product_id`
$this->createIndex(
'{{%idx-check_product-product_id}}',
'{{%check_product}}',
'product_id'
);
// add foreign key for table `{{%product}}`
$this->addForeignKey(
'{{%fk-check_product-product_id}}',
'{{%check_product}}',
'product_id',
'{{%product}}',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
// drops foreign key for table `{{%check}}`
$this->dropForeignKey(
'{{%fk-check_product-check_id}}',
'{{%check_product}}'
);
// drops index for column `check_id`
$this->dropIndex(
'{{%idx-check_product-check_id}}',
'{{%check_product}}'
);
// drops foreign key for table `{{%product}}`
$this->dropForeignKey(
'{{%fk-check_product-product_id}}',
'{{%check_product}}'
);
// drops index for column `product_id`
$this->dropIndex(
'{{%idx-check_product-product_id}}',
'{{%check_product}}'
);
$this->dropTable('{{%check_product}}');
}
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,57 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%product_category}}`.
*/
class m240212_213157_create_product_category_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%product_category}}', [
'id' => $this->primaryKey(),
'title' => $this->string('255')->notNull(),
'parent_id' => $this->integer(11)->defaultValue(0),
'company_id' => $this->integer(11)->notNull(),
'status' => $this->integer(1)->defaultValue(1),
]);
$this->createIndex(
'idx-product_category-company_id',
'product_category',
'company_id'
);
// add foreign key for table `user`
$this->addForeignKey(
'fk-product_category-company_id',
'product_category',
'company_id',
'company',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey(
'fk-product_category-company_id',
'product_category'
);
// drops index for column `author_id`
$this->dropIndex(
'idx-product_category-company_id',
'product_category'
);
$this->dropTable('{{%product_category}}');
}
}