hejianhao
2026-09-01 540ef65220e05b75c183cd3554aaeb554927600a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
SET @apple_user_identifier_column_exists = (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'tcm_app_user'
    AND COLUMN_NAME = 'apple_user_identifier'
);
 
SET @apple_user_identifier_alter_sql = IF(
  @apple_user_identifier_column_exists = 0,
  'ALTER TABLE `tcm_app_user` ADD COLUMN `apple_user_identifier` VARCHAR(128) DEFAULT NULL COMMENT ''苹果用户标识'' AFTER `wechat_bound_at`',
  'SELECT 1'
);
 
PREPARE apple_user_identifier_stmt FROM @apple_user_identifier_alter_sql;
EXECUTE apple_user_identifier_stmt;
DEALLOCATE PREPARE apple_user_identifier_stmt;
 
SET @apple_identity_subject_column_exists = (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'tcm_app_user'
    AND COLUMN_NAME = 'apple_identity_subject'
);
 
SET @apple_identity_subject_alter_sql = IF(
  @apple_identity_subject_column_exists = 0,
  'ALTER TABLE `tcm_app_user` ADD COLUMN `apple_identity_subject` VARCHAR(128) DEFAULT NULL COMMENT ''苹果身份主题标识'' AFTER `apple_user_identifier`',
  'SELECT 1'
);
 
PREPARE apple_identity_subject_stmt FROM @apple_identity_subject_alter_sql;
EXECUTE apple_identity_subject_stmt;
DEALLOCATE PREPARE apple_identity_subject_stmt;
 
SET @apple_bound_at_column_exists = (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'tcm_app_user'
    AND COLUMN_NAME = 'apple_bound_at'
);
 
SET @apple_bound_at_alter_sql = IF(
  @apple_bound_at_column_exists = 0,
  'ALTER TABLE `tcm_app_user` ADD COLUMN `apple_bound_at` DATETIME DEFAULT NULL COMMENT ''苹果绑定时间'' AFTER `apple_identity_subject`',
  'SELECT 1'
);
 
PREPARE apple_bound_at_stmt FROM @apple_bound_at_alter_sql;
EXECUTE apple_bound_at_stmt;
DEALLOCATE PREPARE apple_bound_at_stmt;