- TransferLegacyWeixins中采用增量式

This commit is contained in:
gazebo
2019-08-26 11:44:47 +08:00
parent ea97ad1a6c
commit fcc87c34af

View File

@@ -26,9 +26,13 @@ func TransferLegacyWeixins() (err error) {
// TRUNCATE TABLE casbin_rule;
sql := `
SELECT *
FROM weixins
ORDER BY parentid`
SELECT t1.*
FROM weixins t1
LEFT JOIN user t2 ON t2.mobile = t1.tel
LEFT JOIN auth_bind t3 ON t3.auth_id = t1.openid AND t3.type = 'weixinsns'
LEFT JOIN auth_bind t4 ON t4.auth_id = t1.openid_mini AND t4.type = 'weixinmini'
WHERE t2.id IS NULL OR (t1.openid <> '' AND t3.id IS NULL) OR (t1.openid_mini <> '' AND t4.id IS NULL)
ORDER BY t1.parentid;`
var weixinList []*legacymodel.WeiXins
db := dao.GetDB()
err = dao.GetRows(db, &weixinList, sql)