first commit
This commit is contained in:
33
console/migrations/m130524_201442_init.php
Executable file
33
console/migrations/m130524_201442_init.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
class m130524_201442_init 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('{{%user}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'username' => $this->string()->notNull()->unique(),
|
||||
'auth_key' => $this->string(32)->notNull(),
|
||||
'password_hash' => $this->string()->notNull(),
|
||||
'password_reset_token' => $this->string()->unique(),
|
||||
'email' => $this->string()->notNull()->unique(),
|
||||
|
||||
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||
'created_at' => $this->integer()->notNull(),
|
||||
'updated_at' => $this->integer()->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropTable('{{%user}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use \yii\db\Migration;
|
||||
|
||||
class m190124_110200_add_verification_token_column_to_user_table extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn('{{%user}}', 'verification_token', $this->string()->defaultValue(null));
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropColumn('{{%user}}', 'verification_token');
|
||||
}
|
||||
}
|
30
console/migrations/m230503_111312_create_news_table.php
Executable file
30
console/migrations/m230503_111312_create_news_table.php
Executable file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%news}}`.
|
||||
*/
|
||||
class m230503_111312_create_news_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%news}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'title' => $this->string(),
|
||||
'text' => $this->text(),
|
||||
'slug' => $this->string()->unique()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%news}}');
|
||||
}
|
||||
}
|
33
console/migrations/m230503_151339_create_profile_table.php
Executable file
33
console/migrations/m230503_151339_create_profile_table.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%profile}}`.
|
||||
*/
|
||||
class m230503_151339_create_profile_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%profile}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'user_id' => $this->integer(),
|
||||
'created_at' => $this->timestamp(),
|
||||
'image' => $this->string(),
|
||||
'activity' => $this->tinyInteger()
|
||||
]);
|
||||
$this->addForeignKey('user_foreign', 'profile', 'user_id', 'user', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('user_foreign', 'profile');
|
||||
$this->dropTable('{{%profile}}');
|
||||
}
|
||||
}
|
33
console/migrations/m230503_151354_create_text_table.php
Executable file
33
console/migrations/m230503_151354_create_text_table.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%text}}`.
|
||||
*/
|
||||
class m230503_151354_create_text_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%text}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'profile_id' => $this->integer(),
|
||||
'title' => $this->string(),
|
||||
'text' => $this->text(),
|
||||
'language' => $this->string()
|
||||
]);
|
||||
$this->addForeignKey('profile_foreign', 'text', 'profile_id', 'profile', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('profile_foreign', 'text');
|
||||
$this->dropTable('{{%text}}');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user