create project
This commit is contained in:
3
console/config/.gitignore
vendored
Normal file
3
console/config/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
main-local.php
|
||||
params-local.php
|
||||
test-local.php
|
1
console/config/bootstrap.php
Normal file
1
console/config/bootstrap.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
36
console/config/main.php
Normal file
36
console/config/main.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$params = array_merge(
|
||||
require __DIR__ . '/../../common/config/params.php',
|
||||
require __DIR__ . '/../../common/config/params-local.php',
|
||||
require __DIR__ . '/params.php',
|
||||
require __DIR__ . '/params-local.php'
|
||||
);
|
||||
|
||||
return [
|
||||
'id' => 'app-console',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'bootstrap' => ['log'],
|
||||
'controllerNamespace' => 'console\controllers',
|
||||
'aliases' => [
|
||||
'@bower' => '@vendor/bower-asset',
|
||||
'@npm' => '@vendor/npm-asset',
|
||||
],
|
||||
'controllerMap' => [
|
||||
'fixture' => [
|
||||
'class' => \yii\console\controllers\FixtureController::class,
|
||||
'namespace' => 'common\fixtures',
|
||||
],
|
||||
],
|
||||
'components' => [
|
||||
'log' => [
|
||||
'targets' => [
|
||||
[
|
||||
'class' => \yii\log\FileTarget::class,
|
||||
'levels' => ['error', 'warning'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
5
console/config/params.php
Normal file
5
console/config/params.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
];
|
4
console/config/test.php
Normal file
4
console/config/test.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
];
|
0
console/controllers/.gitkeep
Normal file
0
console/controllers/.gitkeep
Normal file
33
console/migrations/m130524_201442_init.php
Normal file
33
console/migrations/m130524_201442_init.php
Normal 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}}');
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
33
console/migrations/m240110_152351_create_company_table.php
Normal file
33
console/migrations/m240110_152351_create_company_table.php
Normal 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}}');
|
||||
}
|
||||
}
|
52
console/migrations/m240110_153348_create_addresses_table.php
Normal file
52
console/migrations/m240110_153348_create_addresses_table.php
Normal 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}}');
|
||||
}
|
||||
}
|
55
console/migrations/m240110_154916_create_product_table.php
Normal file
55
console/migrations/m240110_154916_create_product_table.php
Normal 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}}');
|
||||
}
|
||||
}
|
75
console/migrations/m240110_155920_create_check_table.php
Normal file
75
console/migrations/m240110_155920_create_check_table.php
Normal 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}}');
|
||||
}
|
||||
}
|
@ -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}}');
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
@ -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}}');
|
||||
}
|
||||
}
|
1
console/models/.gitkeep
Normal file
1
console/models/.gitkeep
Normal file
@ -0,0 +1 @@
|
||||
*
|
2
console/runtime/.gitignore
vendored
Normal file
2
console/runtime/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Reference in New Issue
Block a user