Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] miniadmin后台增加数据源后(填错),修改该数据源(正确),再点击测试,未能依照新的正确的参数执行测试。有缓存? #207

Closed
521chy opened this issue Mar 27, 2024 · 4 comments

Comments

@521chy
Copy link

521chy commented Mar 27, 2024

执行命令并粘贴以下结果。

Command: uname -a && php -v && composer info | grep mine && php --ri swoole

# Paste the result here.

bug描述:

miniadmin后台增加数据源后(填错),修改该数据源(正确),再点击测试,未能依照新的正确的参数执行测试。有缓存?

重现步骤:

@521chy 521chy added the bug label Mar 27, 2024
@zds-s
Copy link
Member

zds-s commented Mar 27, 2024

这块后面可能要砍掉。改为从 database.php 去读数据源。建议你也改为从配置文件设置数据源

@cxyqx
Copy link

cxyqx commented Jun 18, 2024

database.php增加数据源,有否示例没?
return [
'default' => [
'driver' => env('DB_DRIVER', 'mysql'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 3306),
'odbc' => env('ODBC_ENABLE', false),
'odbc_datasource_name' => env('ODBC_DSN'),
'database' => env('DB_DATABASE', 'hyperf'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD'),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'pool' => [
'min_connections' => 1,
'max_connections' => 20,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
'cache' => [
'handler' => RedisHandler::class,
'cache_key' => 'MineAdmin:%s:m:%s:%s:%s',
'prefix' => 'model-cache',
'ttl' => 86400 * 7,
'empty_model_ttl' => 60,
'load_script' => true,
'use_default_value' => false,
],
'commands' => [
'gen:model' => [
'path' => 'app/Model',
'force_casts' => true,
'inheritance' => 'MineModel',
'uses' => 'Mine\MineModel',
'with_comments' => true,
'refresh_fillable' => true,
'visitors' => [
ModelRewriteKeyInfoVisitor::class,
ModelRewriteTimestampsVisitor::class,
ModelRewriteSoftDeletesVisitor::class,
// Hyperf\Database\Commands\Ast\ModelRewriteGetterSetterVisitor::class,
],
],
],
],
'we7' => [
'driver' => env('DB_DRIVER', 'mysql'),
'host' => $config['db']['master']['host'],
'port' => $config['db']['master']['port'],
'database' => $config['db']['master']['database'],
'username' => $config['db']['master']['username'],
'password' => $config['db']['master']['password'],
'charset' => $config['db']['master']['charset'],
'collation' => 'utf8_general_ci',
'prefix' => 'ims_',
'pool' => [
'min_connections' => 1,
'max_connections' => 20,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
],
];
其中默认库前缀为hcz_
we7库前缀为ims_
上述根据多库的格式添加后,只想引入we7例如“ims_user”表数据而不是做读写分离,但实际运行后在we7的数据库中再次获取默认库的所有字段

@cxyqx
Copy link

cxyqx commented Jun 18, 2024

这块后面可能要砍掉。改为从 database.php 去读数据源。建议你也改为从配置文件设置数据源

请看回复,大佬

@zds-s
Copy link
Member

zds-s commented Jun 18, 2024

这块后面可能要砍掉。改为从 database.php 去读数据源。建议你也改为从配置文件设置数据源

请看回复,大佬

这块优先级不高
目前的话,建议

把原先的 default 配置改为新库

原先 default 另起一个库

在开发中通过调整两个库 pool name 来进行快速 crud 开发,生成后端代码后。再手动调整对应的 model 类 pool name

生产环境中再配置正确的 default pool name

这块做个标记,后面和 代码生成器支持 pgsql 一块上

@zds-s zds-s closed this as completed Jun 24, 2024
@zds-s zds-s reopened this Jun 24, 2024
@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 23, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants