1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-27 21:10:24 +08:00
course-tencent-cloud/db/migrations/20200827113559_insert_user_data.php
xiaochong0302 ee20552eeb 1.修正插入的管理帐号数据
2.修正参数类型报错
2020-10-26 19:59:46 +08:00

65 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class InsertUserData extends AbstractMigration
{
public function up()
{
$now = time();
$account = [
'id' => 10000,
'email' => '10000@163.com',
'password' => '1a1e4568f1a3740b8853a8a16e29bc87',
'salt' => 'MbZWxN3L',
'create_time' => $now,
];
$this->table('kg_account')->insert($account)->saveData();
$user = [
'id' => $account['id'],
'name' => '酷瓜云网课',
'avatar' => '/img/avatar/default.png',
'title' => '官方人员',
'about' => '酷瓜云课堂依托腾讯云基础服务使用C扩展框架PHALCON开发',
'admin_role' => 1,
'edu_role' => 2,
'create_time' => $now,
];
$this->table('kg_user')->insert($user)->saveData();
$imUser = [
'id' => $user['id'],
'name' => $user['name'],
'avatar' => $user['avatar'],
'create_time' => $now,
];
$this->table('kg_im_user')->insert($imUser)->saveData();
}
public function down()
{
$id = 10000;
$sql = sprintf('DELETE FROM kg_account WHERE id = %d', $id);
$this->execute($sql);
$sql = sprintf('DELETE FROM kg_user WHERE id = %d', $id);
$this->execute($sql);
$sql = sprintf('DELETE FROM kg_im_user WHERE id = %d', $id);
$this->execute($sql);
}
}