feat: S0 主键改雪花(DDL 去 identity + 实体 ASSIGN_ID + 雪花配置)
为什么:自增主键把 ID 分配锁在单库序列上,分库分表时无法横向扩展。趁线上业务数据 近零(只有系统种子表有量)先改,代价最低。 - sql/schema.sql、sql/schema-phase1.sql、sql/partition-maintenance.sql:61 处 GENERATED BY DEFAULT AS IDENTITY 去掉,主键改 BIGINT 无默认值 - 52 个实体 @TableId IdType.AUTO -> IdType.ASSIGN_ID;两个入口 id-type: assign_id, 并加 global-config.sequence.worker-id/datacenter-id(单机固定值,多实例需按实例分配) - 新增 sql/migrate-s0-snowflake.sql:存量库幂等迁移,走 DROP IDENTITY 保留数据,不重建表 - 实测:三份建表脚本在新库连跑两遍幂等;线上 57 张表 identity 归零; watch_history/playback_ticket/order_event 的主键与唯一索引仍含分区键
This commit is contained in:
1 parent
6833e01e1f
commit
37c9a141d3
58 files changed
+174
-115
No files matched your search
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_account_deletion")
|
||||
public class AppAccountDeletion {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private Long userId;
|
||||
/** pending/cancelled/completed */
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user")
|
||||
public class AppUser {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/** 对外用户标识,接口只暴露 uid,不暴露自增 ID */
|
||||
private String uid;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user_ban_record")
|
||||
public class AppUserBanRecord {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private Long userId;
|
||||
/** BAN/LIMIT/MUTE */
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user_consent")
|
||||
public class AppUserConsent {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private String scene;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user_credential")
|
||||
public class AppUserCredential {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private Long userId;
|
||||
/** PHONE/EMAIL/APPLE/GOOGLE */
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user_device")
|
||||
public class AppUserDevice {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private String deviceId;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user_otp")
|
||||
public class AppUserOtp {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private String scene;
|
||||
private String targetType;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
|
||||
@TableName("app_user_session")
|
||||
public class AppUserSession {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private String refreshTokenHash;
|
||||
|
||||
Reference in new issue
Block a user