diff --git a/django_migration_linter/sql_analyser/mysql.py b/django_migration_linter/sql_analyser/mysql.py index f04da36..6adeb0a 100644 --- a/django_migration_linter/sql_analyser/mysql.py +++ b/django_migration_linter/sql_analyser/mysql.py @@ -27,3 +27,13 @@ class MySqlAnalyser(BaseAnalyser): "mode": "one_liner", } ] + + @staticmethod + def detect_column(sql): + if isinstance(sql, str): + regex_result = re.search("COLUMN [`\"'](.*?)[`\"']", sql, re.IGNORECASE) + if regex_result: + return regex_result.group(1) + regex_result = re.search("MODIFY [`\"'](.*?)[`\"']", sql, re.IGNORECASE) + if regex_result: + return regex_result.group(1) diff --git a/django_migration_linter/sql_analyser/sqlite.py b/django_migration_linter/sql_analyser/sqlite.py index 219abf0..826896b 100644 --- a/django_migration_linter/sql_analyser/sqlite.py +++ b/django_migration_linter/sql_analyser/sqlite.py @@ -67,3 +67,13 @@ class SqliteAnalyser(BaseAnalyser): }, {"code": "ADD_UNIQUE", "fn": has_add_unique, "mode": "transaction"}, ] + + @staticmethod + def detect_table(sql): + if isinstance(sql, str): + regex_result = re.search("TABLE [`\"'](.*?)[`\"']", sql, re.IGNORECASE) + if regex_result: + return regex_result.group(1) + regex_result = re.search("ON [`\"'](.*?)[`\"']", sql, re.IGNORECASE) + if regex_result: + return regex_result.group(1)