Skip to content

Commit

Permalink
修复2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Dec 1, 2024
1 parent 9487990 commit 16b207f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
2 changes: 2 additions & 0 deletions app/Controller/Home/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace App\Controller\Home;

use App\Infra\Entity\Platform;
use App\Infra\Entity\SearchPlan;
use Leevel\View\Proxy\View;

/**
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"require-dev": {
"codedungeon/php-cli-colors": "^1.12.2",
"robmorgan/phinx": "^0.16.0",
"zircote/swagger-php": "^4.9.2",
"swoole/ide-helper": "^5.1.2"
},
Expand Down
7 changes: 7 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
// 连接的存活时间(单位为秒)
'keep_alive_duration' => (int) App::proxy()->env('DATABASE_MYSQL_POOL_KEEP_ALIVE_DURATION', 60),
],
'data' => [
// driver
'driver' => 'mysql',

// 数据库名字
'name' => App::proxy()->env('DATABASE_NAME_PREFIX', ''),
],
'common' => [
// driver
'driver' => 'mysql',
Expand Down
26 changes: 4 additions & 22 deletions database/common/migrations/20230326065016_platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;
use Leevel\Database\Migrations\Migration;

final class Platform extends AbstractMigration
final class Platform extends Migration
{
public function up(): void
protected function sql(): string
{
$this->struct();
$this->seed();
}

public function down(): void
{
$this->table('platform')->drop()->save();
}

private function struct(): void
{
$sql = <<<'EOT'
return <<<'EOT'
CREATE TABLE `platform` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '平台ID',
`platform_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '平台编号 自增ID+3位数据库+2位表名',
Expand All @@ -36,15 +25,8 @@ private function struct(): void
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_platform_id` (`platform_id`) USING BTREE COMMENT '平台编号'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='平台';
EOT;
$this->execute($sql);
}
private function seed(): void
{
$sql = <<<'EOT'
INSERT INTO `platform`(`id`, `platform_id`, `num`, `name`, `full_name`, `status`, `create_at`, `update_at`, `delete_at`, `create_account`, `update_account`, `version`) VALUES (7550678834745344, 100000, 'jrdh', '今日订货', '今日订货平台', 1, '2023-03-26 04:29:12', '2023-03-26 04:32:11', 0, 0, 0, 0);
EOT;
$this->execute($sql);
}
}
22 changes: 4 additions & 18 deletions database/data/migrations/20230412170014_search_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;
use Leevel\Database\Migrations\Migration;

final class SearchPlan extends AbstractMigration
final class SearchPlan extends Migration
{
public function up(): void
protected function sql(): string
{
$this->struct();
$this->seed();
}

public function down(): void
{
$this->table('search_plan')->drop()->save();
}

private function struct(): void
{
$sql = <<<'EOT'
return <<<'EOT'
CREATE TABLE `search_plan` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`platform_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '平台ID',
Expand All @@ -38,8 +27,5 @@ private function struct(): void
KEY `idx_platform_company` (`platform_id`,`company_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='常用搜索';
EOT;
$this->execute($sql);
}

private function seed(): void {}
}

0 comments on commit 16b207f

Please sign in to comment.