add city, customer and card model + crud
This commit is contained in:
48
console/migrations/m150925_194508_add__table__customer.php
Normal file
48
console/migrations/m150925_194508_add__table__customer.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m150925_194508_add__table__customer 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('{{%customer}}', [
|
||||
'id_customer' => $this->primaryKey(),
|
||||
'id_customer_card' => $this->integer(),
|
||||
'id_user' => $this->integer(),
|
||||
'id_partner_card' => $this->integer(),
|
||||
'id_proposer' =>$this->integer(),
|
||||
'name' => $this->string(128),
|
||||
'email' => $this->string(255),
|
||||
'password' => $this->string(32),
|
||||
'phone' => $this->string(20),
|
||||
'sex' => $this->smallInteger(),
|
||||
'date_stundent_card_expire' => $this->date(),
|
||||
'birthdate' => $this->date(),
|
||||
'image' => $this->string(255),
|
||||
'description' => $this->string(255),
|
||||
'tax_number' => $this->string(20),
|
||||
'country' => $this->string(20),
|
||||
'zip' => $this->string(8),
|
||||
'city' => $this->string(30),
|
||||
'address' => $this->string(255),
|
||||
'created_at' => $this->timestamp()->notNull(),
|
||||
'updated_at' => $this->timestamp()->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m150925_194508_add__table__customer cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
43
console/migrations/m150925_201715_add__table__card.php
Normal file
43
console/migrations/m150925_201715_add__table__card.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m150925_201715_add__table__card 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('{{%card}}', [
|
||||
'id_card' => $this->primaryKey(),
|
||||
'number' => $this->string(20)->notNull(),
|
||||
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||
'type' => $this->integer(11)->notNull(),
|
||||
'created_at' => $this->timestamp()->notNull(),
|
||||
'updated_at' => $this->timestamp()->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m150925_201715_add__table__card cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
59
console/migrations/m150926_123638_add__table__city.php
Normal file
59
console/migrations/m150926_123638_add__table__city.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m150926_123638_add__table__city 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('{{%city}}', [
|
||||
'id_city' => $this->primaryKey(),
|
||||
'zip' => $this->string(8)->notNull(),
|
||||
'name' => $this->string(64)->notNull(),
|
||||
'city_code' => $this->string(2)->notNull(),
|
||||
'latitude' => $this->float(),
|
||||
'longitude' => $this->float() ,
|
||||
'cso_code' => $this->integer(11) ,
|
||||
'rig_id' => $this->integer(11) ,
|
||||
'range' => $this->float() ,
|
||||
'population' =>$this->integer(11) ,
|
||||
'homes' => $this->integer(11) ,
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m150926_123638_add__table__city cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
id_city
|
||||
zip
|
||||
name
|
||||
city_code
|
||||
latitude
|
||||
longitude
|
||||
cso_code
|
||||
rig_id
|
||||
cit_range
|
||||
population
|
||||
homes
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user