Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use yii\db\Migration;
- /**
- * Class m180620_034536_auth
- */
- class m180620_034536_auth extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $this->createTable('user', [
- 'id' => $this->primaryKey(),
- 'username' => $this->string()->notNull(),
- 'auth_key' => $this->string()->notNull(),
- 'password_hash' => $this->string()->notNull(),
- 'password_reset_token' => $this->string(),
- 'email' => $this->string()->notNull(),
- 'status' => $this->smallInteger()->notNull()->defaultValue(10),
- 'created_at' => $this->integer()->notNull(),
- 'updated_at' => $this->integer()->notNull(),
- ]);
- $this->createTable('auth', [
- 'id' => $this->primaryKey(),
- 'user_id' => $this->integer()->notNull(),
- 'source' => $this->string()->notNull(),
- 'source_id' => $this->string()->notNull(),
- ]);
- $this->addForeignKey('fk-auth-user_id-user-id', 'auth', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE');
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- $this->dropTable('auth');
- $this->dropTable('user');
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "m180620_034536_auth cannot be reverted.\n";
- return false;
- }
- */
- }
Add Comment
Please, Sign In to add comment