added migrations

This commit is contained in:
Antonio Ramirez
2016-12-10 21:33:29 +01:00
parent 6d47dcaf22
commit 0faf61f044
4 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?php
class m000000_000001_create_user_table extends \yii\db\Migration
{
public function up()
{
$this->createTable('{{%user}}', [
'id' => $this->primaryKey(),
'username' => $this->string(255)->notNull(),
'email' => $this->string(255)->notNull(),
'password_hash' => $this->string(60)->notNull(),
'auth_key' => $this->string(32)->notNull(),
'unconfirmed_email' => $this->string(255),
'registration_id' => $this->string(45),
'confirmed_at' => $this->integer(),
'blocked_at' => $this->integer(),
'updated_at' => $this->integer()->notNull(),
'created_at' =>$this->integer()->notNull()
]);
$this->createIndex('idx_user_username', '{{%user}}', 'username', true);
$this->createIndex('idx_user_email', '{{%user}}', 'email', true);
}
public function down()
{
$this->dropTable('{{%user}}');
}
}

View File

@ -0,0 +1,30 @@
<?php
class m000000_000002_create_profile_table extends \yii\db\Migration
{
public function up()
{
$this->createTable(
'{{%profile}}',
[
'user_id' => $this->primaryKey(),
'name' => $this->string(255),
'public_email' => $this->string(255),
'gravatar_email' => $this->string(255),
'gravatar_id' => $this->string(32),
'location' => $this->string(255),
'website'=> $this->string(255),
'timezone' => $this->string(40),
'bio' => $this->text()
]
);
$this->addForeignKey('fk_profile_user', '{{%profile}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'RESTRICT');
}
public function down()
{
$this->dropTable('{{%profile}}');
}
}

View File

@ -0,0 +1,47 @@
<?php
class m000000_000003_create_social_account_table extends \yii\db\Migration
{
public function up()
{
$this->createTable(
'{{%social_account}}',
[
'id' => $this->primaryKey(),
'user_id' => $this->integer(),
'provider' => $this->string(255)->notNull(),
'client_id' => $this->string(255)->notNull(),
'code' => $this->string(32),
'email' => $this->string(255),
'username' => $this->string(255),
'data' => $this->text(),
'created_at' => $this->integer()
]
);
$this->createIndex(
'idx_social_account_provider_client_id',
'{{%social_account}}',
['provider', 'client_id'],
true
);
$this->createIndex('idx_social_account_code', '{{%social_account}}', 'code', true);
$this->addForeignKey(
'fk_social_account_user',
'{{%social_account}}',
'user_id',
'{{%user}}',
'id',
'CASCADE',
'RESTRICT'
);
}
public function down()
{
$this->dropTable('{{%social_account}}');
}
}

View File

@ -0,0 +1,27 @@
<?php
class m000000_000004_create_token_table extends \yii\db\Migration
{
public function up()
{
$this->createTable(
'{{%token}}',
[
'user_id' => $this->integer(),
'code' => $this->string(32)->notNull(),
'type' => $this->smallInteger(6)->notNull(),
'created_at' => $this->integer()->notNull()
]
);
$this->createIndex('idx_token_user_id_code_type', '{{%token}}', ['user_id', 'code', 'type'], true);
$this->addForeignKey('fk_token_user', '{{%token}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'RESTRICT');
}
public function down()
{
$this->dropTable('{{%token}}');
}
}