Handle creating a unique index as adding a unique constraint

This commit is contained in:
David Wobrock committed 2022-01-28 21:23:44 +01:00
1 parent 3fbc720650
commit 3219f9cf8a
4 files changed
+42 -25

No files matched your search

@@ -3,23 +3,6 @@ import re
from .base import BaseAnalyser
def has_add_unique(sql_statements, **kwargs):
regex_result = None
for sql in sql_statements:
regex_result = re.search('CREATE UNIQUE INDEX .* ON (".*?")', sql)
if regex_result:
break
if not regex_result:
return False
concerned_table = regex_result.group(1)
table_is_added_in_transaction = any(
sql.startswith("CREATE TABLE {}".format(concerned_table))
for sql in sql_statements
)
return not table_is_added_in_transaction
class SqliteAnalyser(BaseAnalyser):
migration_tests = [
{
@@ -54,12 +37,6 @@ class SqliteAnalyser(BaseAnalyser):
"mode": "transaction",
"type": "error",
},
{
"code": "ADD_UNIQUE",
"fn": has_add_unique,
"mode": "transaction",
"type": "error",
},
]
@staticmethod