fix: 幂等建表跳过索引语句(避免Duplicate key name)

This commit is contained in:
yumoqing 2026-08-16 19:19:10 +08:00
parent 21920ad457
commit c5891a79f4

View File

@ -90,6 +90,9 @@ async def main():
s = re.sub(r'(?i)CREATE\s+TABLE\s+(`?\w+`?)', r'CREATE TABLE IF NOT EXISTS \1', s)
if not s.strip():
continue
# 跳过索引/约束语句(表已存在时索引也已存在,重复建会 Duplicate key name
if re.match(r'(?i)\s*(CREATE\s+(UNIQUE\s+)?INDEX|ALTER\s+TABLE)', s):
continue
await sor.execute(s, {})
n += 1
print(f' tables: {mod} ensured ({n} statements, idempotent)')