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

[DB]配置项 TablePrefix 不生效 #1909

Open
igotcha opened this issue Apr 8, 2024 · 2 comments
Open

[DB]配置项 TablePrefix 不生效 #1909

igotcha opened this issue Apr 8, 2024 · 2 comments

Comments

@igotcha
Copy link

igotcha commented Apr 8, 2024

Your config.toml

[DB]
# postgres: host=%s port=%s user=%s dbname=%s password=%s sslmode=%s
# postgres: DSN="host=127.0.0.1 port=5432 user=root dbname=n9e_v6 password=1234 sslmode=disable"
DSN = "root:1234@tcp(127.0.0.1:3306)/n9e_v6?charset=utf8mb4&parseTime=True&loc=Local&allowNativePasswords=true"
# enable debug mode or not
Debug = false
# mysql postgres
DBType = "mysql"
# unit: s
MaxLifetime = 7200
# max open connections
MaxOpenConns = 150
# max idle connections
MaxIdleConns = 50
# table prefix
TablePrefix = "someprefix_"
# enable auto migrate or not
# EnableAutoMigrate = false

Relevant logs

2024-04-08 17:04:29.847451 ERROR ormx/ormx.go:66 /home/runner/work/nightingale/nightingale/models/common.go:21 Error 1146: Table 'n9e_v6.role_operation' doesn't exist
[0.254ms] [rows:0] SELECT count(*) FROM `role_operation` WHERE operation = '/alert-mutes/put' and role_name = 'Standard'
2024-04-08 17:04:29.847538 ERROR migrate/migrate.go:132 check role operation exists failed, Error 1146: Table 'n9e_v6.role_operation' doesn't exist
2024-04-08 17:04:29.847799 ERROR ormx/ormx.go:66 /home/runner/work/nightingale/nightingale/models/common.go:21 Error 1146: Table 'n9e_v6.role_operation' doesn't exist
[0.233ms] [rows:0] SELECT count(*) FROM `role_operation` WHERE operation = '/log/index-patterns' and role_name = 'Standard'
2024-04-08 17:04:29.847820 ERROR migrate/migrate.go:132 check role operation exists failed, Error 1146: Table 'n9e_v6.role_operation' doesn't exist
2024-04-08 17:04:29.848052 ERROR ormx/ormx.go:66 /home/runner/work/nightingale/nightingale/models/common.go:21 Error 1146: Table 'n9e_v6.role_operation' doesn't exist
[0.204ms] [rows:0] SELECT count(*) FROM `role_operation` WHERE operation = '/help/variable-configs' and role_name = 'Standard'
2024-04-08 17:04:29.848064 ERROR migrate/migrate.go:132 check role operation exists failed, Error 1146: Table 'n9e_v6.role_operation' doesn't exist
2024-04-08 17:04:29.848263 ERROR ormx/ormx.go:66 /home/runner/work/nightingale/nightingale/models/common.go:21 Error 1146: Table 'n9e_v6.role_operation' doesn't exist
[0.176ms] [rows:0] SELECT count(*) FROM `role_operation` WHERE operation = '/permissions' and role_name = 'Admin'
2024-04-08 17:04:29.848290 ERROR migrate/migrate.go:132 check role operation exists failed, Error 1146: Table 'n9e_v6.role_operation' doesn't exist
2024-04-08 17:04:29.848516 ERROR ormx/ormx.go:66 /home/runner/work/nightingale/nightingale/models/common.go:21 Error 1146: Table 'n9e_v6.role_operation' doesn't exist
[0.205ms] [rows:0] SELECT count(*) FROM `role_operation` WHERE operation = '/ibex-settings' and role_name = 'Standard'
2024-04-08 17:04:29.848543 ERROR migrate/migrate.go:132 check role operation exists failed, Error 1146: Table 'n9e_v6.role_operation' doesn't exist
2024-04-08 17:04:29.850073 ERROR ormx/ormx.go:66 /home/runner/work/nightingale/nightingale/models/user.go:227 Error 1146: Table 'n9e_v6.users' doesn't exist

System info

n9e 7.0.0-beta.2

Steps to reproduce

  1. 按 TablePrefix 建表: CREATE TABLE IF NOT EXISTS someprefix_user_group (
  2. 以 TablePrefix = "someprefix_" 启动 n9e
  3. 报错, 无法启动

Expected behavior

访问表名: someprefix_role_operation

Actual behavior

访问表名: role_operation

Additional info

按gorm的实现, 如果model定义了 TableName() 则优先使用, 导致 NamingStrategy 不生效

@igotcha
Copy link
Author

igotcha commented Apr 9, 2024

main...igotcha:nightingale:main
这样应该就可以了

@710leo
Copy link
Member

710leo commented Apr 22, 2024

暂时还没人力调整这块哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants