diff --git a/app/Controller/Home/Index.php b/app/Controller/Home/Index.php index 15a7ae5f..05b90fa6 100644 --- a/app/Controller/Home/Index.php +++ b/app/Controller/Home/Index.php @@ -4,6 +4,8 @@ namespace App\Controller\Home; +use App\Infra\Entity\Platform; +use App\Infra\Entity\SearchPlan; use Leevel\View\Proxy\View; /** diff --git a/composer.json b/composer.json index 500e999e..459c4293 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/config/database.php b/config/database.php index cd94334a..a38d0de5 100644 --- a/config/database.php +++ b/config/database.php @@ -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', diff --git a/database/common/migrations/20230326065016_platform.php b/database/common/migrations/20230326065016_platform.php index 2a39d60b..7e32f9af 100644 --- a/database/common/migrations/20230326065016_platform.php +++ b/database/common/migrations/20230326065016_platform.php @@ -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位表名', @@ -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); } } diff --git a/database/data/migrations/20230412170014_search_plan.php b/database/data/migrations/20230412170014_search_plan.php index 1d5e4371..18b170fa 100644 --- a/database/data/migrations/20230412170014_search_plan.php +++ b/database/data/migrations/20230412170014_search_plan.php @@ -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', @@ -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 {} }