fix shared database account sequence initialization
This commit is contained in:
@@ -1351,6 +1351,10 @@ func nextUserAccountNo(ctx context.Context, tx *sqlx.Tx) (uint32, bool, error) {
|
||||
return 0, false, nil
|
||||
}
|
||||
|
||||
if _, err := tx.ExecContext(ctx, `INSERT IGNORE INTO im_user_account_sequences(id,next_value)
|
||||
SELECT 1,GREATEST(COALESCE(MAX(account_no),999),999) FROM im_users WHERE account_no>0`); err != nil {
|
||||
return 0, true, err
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, `UPDATE im_user_account_sequences
|
||||
SET next_value=GREATEST(next_value,(SELECT GREATEST(COALESCE(MAX(account_no),999),999) FROM im_users WHERE account_no>0))
|
||||
WHERE id=1`); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user