diff --git a/scripts/create_tables.py b/scripts/create_tables.py index 8f60728..85f5a44 100644 --- a/scripts/create_tables.py +++ b/scripts/create_tables.py @@ -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)')