Commit fed7b063 by Junaid Rahman pv

created migrations for business and location(state,district)

parent 61e93916
<?php
use yii\db\Migration;
class m160831_080848_location extends Migration
{
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%state}}', [
'id' => $this->primaryKey(),
'name' => $this->string(1024)->notNull(),
'slug' => $this->string(1024),
'status' => $this->smallInteger(6),
'created_at' => $this->integer(11),
'updated_at' => $this->integer(11),
], $tableOptions);
$this->createTable('{{%district}}', [
'id' => $this->primaryKey(),
'state_id' => $this->integer()->notNull(),
'name' => $this->string(1024)->notNull(),
'slug' => $this->string(1024),
'status' => $this->smallInteger(6),
'created_at' => $this->integer(11),
'updated_at' => $this->integer(11),
], $tableOptions);
$this->createIndex('idx_state_name', '{{%state}}', 'name');
$this->createIndex('idx_state_id', '{{%district}}', 'state_id');
$this->createIndex('idx_district_name', '{{%district}}', 'name');
$this->addForeignKey('fk_state_id', '{{%district}}', 'state_id', '{{%state}}', 'id', 'RESTRICT', 'RESTRICT');
}
public function safeDown()
{
$this->dropForeignKey('fk_state_id', '{{%district}}');
$this->dropTable('{{%district}}');
$this->dropTable('{{%state}}');
}
}
<?php
use yii\db\Migration;
class m160831_092919_business extends Migration
{
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%business}}', [
'id' => $this->primaryKey(),
'category_id' => $this->integer()->notNull(),
'district_id' => $this->integer()->notNull(),
'domain_name' => $this->string(255)->notNull(),
'name' => $this->string(512),
'slug' => $this->string(1024),
'address' => $this->string(1024),
'landmark' => $this->string(500),
'mobile_no' => $this->string(512),
'toll_free_no' => $this->string(512),
'contact_no' => $this->string(150),
'fax' => $this->string(512),
'email' => $this->string(1024),
'website' => $this->string(1024),
'description' => $this->text(),
'logo_base_url' => $this->string(1024),
'logo_path' => $this->string(1024),
'latitude' => $this->string(30),
'logitude' => $this->string(30),
'status' => $this->smallInteger(6),
'created_at' => $this->integer(11),
'updated_at' => $this->integer(11),
], $tableOptions);
$this->createIndex('idx-business-category_id', '{{%business}}', 'category_id');
$this->createIndex('idx-business-district_id', '{{%business}}', 'district_id');
$this->createIndex('idx-business-domain_name', '{{%business}}', 'domain_name');
$this->createIndex('idx-business-email', '{{%business}}', 'email');
$this->addForeignKey('fk_category_id', '{{%business}}', 'category_id', '{{%category}}', 'id', 'RESTRICT', 'RESTRICT');
$this->addForeignKey('fk_district_id', '{{%business}}', 'district_id', '{{%district}}', 'id', 'RESTRICT', 'RESTRICT');
}
public function safeDown()
{
$this->dropForeignKey('fk_district_id', '{{%business}}');
$this->dropForeignKey('fk_category_id', '{{%business}}');
$this->dropIndex('idx-business-email', '{{%business}}');
$this->dropIndex('idx-business-domain_name', '{{%business}}');
$this->dropIndex('idx-business-district_id', '{{%business}}');
$this->dropIndex('idx-business-category_id', '{{%business}}');
$this->dropTable('{{%business}}');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment