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

sqlite数据库迁移到mysql数据库出现字段类型不一致的问题,token下的models字段为啥在mysql下被限定为了191的长度 #1483

Open
4 tasks done
ConleyKong opened this issue May 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ConleyKong
Copy link

ConleyKong commented May 29, 2024

例行检查

  • 我已确认目前没有类似 issue
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,尤其是常见问题部分
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • [x 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

问题描述
先前使用docker部署的sqlite版本,积累了一定数据,想要将数据迁移到mysql下但是数据迁移成功后使用docker-compose启动连接mysql后会出现自动的alter字段的问题,sqlite下的token表的models字段text是合理的,但是启动的docker-compose连接mysql却要将其改为varchar(191),不太理解是什么原因

复现步骤
首先将sqlite的数据使用 sqlite3mysql -f one-api.db -d one_api -u xxx -p 迁移到mysql数据库,然后使用docker-compose启动oneapi并连接该数据库会出现异常无法启动,原因就是字段格式冲突

预期结果
token下的models实际上是text类型是合理的,如果限定为191后,有些token下支持特别多模型的情形应该就会有异常吧?

相关截图

one-api-1 | [SYS] 2024/05/29 - 20:18:56 | One API v0.6.6-alpha.15 started
one-api-1 | [SYS] 2024/05/29 - 20:18:56 | using MySQL as database
one-api-1 | [SYS] 2024/05/29 - 20:18:56 | database migration started
one-api-1 |
one-api-1 | 2024/05/29 20:18:56 /build/model/main.go:117 Error 1406 (22001): Data too long for column 'models' at row 1
one-api-1 | [8.714ms] [rows:0] ALTER TABLE tokens MODIFY COLUMN models varchar(191) DEFAULT ''
one-api-1 | [FATAL] 2024/05/29 - 20:18:56 | [failed to initialize database: Error 1406 (22001): Data too long for column 'models' at row 1]
one-api-1 exited with code 0
one-api-1 | [SYS] 2024/05/29 - 20:18:56 | One API v0.6.6-alpha.15 started
one-api-1 | [SYS] 2024/05/29 - 20:18:56 | using MySQL as database
one-api-1 | [SYS] 2024/05/29 - 20:18:56 | database migration started

@ConleyKong ConleyKong added the bug Something isn't working label May 29, 2024
@JuneYaooo
Copy link

+1

@fangkth
Copy link

fangkth commented Jan 29, 2025

确实啊,为啥要限制models是varchar(191),一个令牌里模型多了就报错。你自己改了吧,每次启动oneapi就报错。简直了。他那个初始化应该是在源码里搞的吧,该没法改。

@songquanpeng
Copy link
Owner

近两天处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants