work on inventory
This commit is contained in:
58
console/migrations/m160306_130115_add_inventory_item.php
Normal file
58
console/migrations/m160306_130115_add_inventory_item.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160306_130115_add_inventory_item 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('{{%inventory}}', [
|
||||
'id_inventory' => $this->primaryKey(),
|
||||
'id_user' => $this->integer(11),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
], $tableOptions);
|
||||
|
||||
$this->createTable('{{%inventory_item}}', [
|
||||
'id_inventory_item' => $this->primaryKey(),
|
||||
'id_inventory' => $this->integer(11),
|
||||
'count_in' => $this->integer(11),
|
||||
'count_sold' => $this->integer(11),
|
||||
'count' => $this->integer(11),
|
||||
'type' => $this->integer(11),
|
||||
'id_product' => $this->integer(11),
|
||||
'id_inventory_group' => $this->integer(11),
|
||||
'id_user' => $this->integer(11),
|
||||
'last_inventroy_at' => $this->dateTime(),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
], $tableOptions);
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160306_130115_add_inventory_item cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160307_174038_alter__tablle__inventory_item__add__column_id_inventory_prev__count_prev extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn("inventory_item", "id_inventory_item_prev", "int");
|
||||
$this->addColumn("inventory_item", "count_prev", "int");
|
||||
$this->dropColumn("inventory_item", 'last_inventroy_at');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160307_174038_alter__tablle__inventory_item__add__column_id_inventory_prev__count_prev cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user