迁移去重与改号:消除与 main 的 000050-053 撞号

- 删除 dev 的 000051_user_token_version(main 的 000052_user_token_version 已实现同列)
- order_list_least_privilege / file_upload_owners / cleanup_index 改号为 000067-000069
- 000068 改为 CREATE TABLE IF NOT EXISTS、000069 改为条件加索引,兼容已执行旧编号的历史库
This commit is contained in:
yml2213
2026-09-05 11:54:53 +08:00
parent 369b0647bb
commit 0c37c7e659
5 changed files with 22 additions and 21 deletions
@@ -1,10 +0,0 @@
-- +goose Up
-- 用户会话版本:冻结、改密和退出时递增,立即撤销旧 access/refresh token。
ALTER TABLE users
ADD COLUMN token_version BIGINT NOT NULL DEFAULT 1 COMMENT '用户令牌版本';
-- +goose Down
ALTER TABLE users
DROP COLUMN token_version;
@@ -1,10 +0,0 @@
-- +goose Up
-- 为长期未关联上传归属记录的定时清理提供索引。
ALTER TABLE file_upload_owners
ADD KEY idx_file_upload_owners_created_at (created_at);
-- +goose Down
ALTER TABLE file_upload_owners
DROP INDEX idx_file_upload_owners_created_at;
@@ -1,7 +1,7 @@
-- +goose Up
-- 私有文件上传归属:在业务记录写入前,仅允许上传者预览自己的临时文件。
CREATE TABLE file_upload_owners (
CREATE TABLE IF NOT EXISTS file_upload_owners (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT UNSIGNED NOT NULL,
object_key VARCHAR(512) NOT NULL,
@@ -0,0 +1,21 @@
-- +goose Up
-- 为长期未关联上传归属记录的定时清理提供索引。
-- 兼容历史上已按旧编号执行过该索引的数据库,重复执行时跳过。
SET @idx_exists := (
SELECT COUNT(*) FROM information_schema.statistics
WHERE table_schema = DATABASE()
AND table_name = 'file_upload_owners'
AND index_name = 'idx_file_upload_owners_created_at'
);
SET @ddl := IF(@idx_exists > 0,
'SELECT 1',
'ALTER TABLE file_upload_owners ADD KEY idx_file_upload_owners_created_at (created_at)');
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- +goose Down
ALTER TABLE file_upload_owners
DROP INDEX idx_file_upload_owners_created_at;