add migrateion add_table_product
This commit is contained in:
parent
3e164bb19e
commit
1eae1b3000
49
console/migrations/m150922_133505_add__table__product.php
Normal file
49
console/migrations/m150922_133505_add__table__product.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m150922_133505_add__table__product 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('{{%product}}', [
|
||||||
|
'id_product' => $this->primaryKey(),
|
||||||
|
'id_product_type' => $this->integer()->notNull(),
|
||||||
|
'id_account' => $this->integer()->notNull(),
|
||||||
|
'product_number' => $this->string(20),
|
||||||
|
'barcode' => $this->string(20),
|
||||||
|
'purchase_price' => $this->integer(),
|
||||||
|
'sale_price' => $this->integer(),
|
||||||
|
'profit_margins' => $this->integer(),
|
||||||
|
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||||
|
'description' => $this->string(255),
|
||||||
|
'created_at' => $this->timestamp()->notNull(),
|
||||||
|
'updated_at' => $this->timestamp()->notNull(),
|
||||||
|
], $tableOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m150922_133505_add__table__product cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user