问题描述
我刚遇到一个我无法解决的问题.
I've just run into an issue which I'm not able to solve.
我有一个数据库表project_queues
用作队列,我在其中存储一些记录.处理记录后,它们将被删除.Rails构建record.destroy
在触发MySql数据库上的DELETE record FROM table
的循环中调用删除.
I have a database table project_queues
which is used as a queue, where I store some records. When the records are processed, they are deleted.Deletion is invoked by rails construction record.destroy
in a loop which triggers DELETE record FROM table
on MySql database.
但是现在我注意到,在表project_queues
中, autoIncrement Id (主键)已设置回 1 . (这损坏了我在审计表中的引用.同一记录现在指向多个不同的项目队列)
But now I've noticed, that in the table project_queues
the autoIncrement Id (primary key) was set up back to 1. (Which damaged my references in the audit table. The Same record now points to multiple different project queues)
show create table project_queues;
CREATE TABLE `project_queues` (
`id` int(11) NOT NULL AUTO_INCREMENT,
...
...
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=1
我不使用TRUNCATE project_queues
或删除表构造并在代码中再次创建它.
I do not use TRUNCATE project_queues
or drop the table construction and created it again in code.
有人像我一样遇到类似的问题吗?我也没有在日志中找到任何异常.
Did somebody run into a similar issue like me? I can't find any anomalies in the log either.
我正在使用 Rails 5.2.3 , MariaDB 10.1 .
从应用程序到数据库的连接强制执行以下SQL模式:
The connection from the application to database enforces this SQL modes:
- NO_AUTO_VALUE_ON_ZERO
- STRICT_ALL_TABLES
- NO_AUTO_CREATE_USER
- NO_ENGINE_SUBSTITUTION
- NO_ZERO_DATE
- NO_ZERO_IN_DATE
- ERROR_FOR_DIVISION_BY_ZERO
但是我不认为这些与AI有关.
But I don't think that these have something to do with AI.
推荐答案
已解决
我已经将10.1.29-MariaDB MariaDB Server
升级到10.2.8-MariaDB MariaDB Server
版本> = 10.2.4 解决了自动增量值的重置
Version >= 10.2.4 has solved the resetting of Auto Increment value
这篇关于自动增量已自动重置为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!