# Path: django_migration_linter/sql_analyser/analyser.py
# def analyse_sql_statements(
#     sql_analyser_class, sql_statements, exclude_migration_tests=None
# ):
#     sql_analyser = sql_analyser_class(exclude_migration_tests)
#     sql_analyser.analyse(sql_statements)
#     return sql_analyser.errors, sql_analyser.ignored, sql_analyser.warnings
# 
# def get_sql_analyser_class(database_vendor, analyser_string=None):
#     if analyser_string:
#         return get_sql_analyser_from_string(analyser_string)
#     return get_sql_analyser_class_from_db_vendor(database_vendor)


import unittest
from django_migration_linter.sql_analyser import (
    analyse_sql_statements,
    get_sql_analyser_class,
)

    def test_alter_column(self):
        sql = [
            'ALTER TABLE "app_alter_column_a" RENAME TO "app_alter_column_a__old";',
            'CREATE TABLE "app_alter_column_a" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "field" varchar(10) NULL);',
            'INSERT INTO "app_alter_column_a" ("id", "field") SELECT "id", "field" FROM "app_alter_column_a__old";',
            'DROP TABLE "app_alter_column_a__old";',
        ]
        self.assertValidSql(sql)

    def test_alter_column_after_django22(self):
        sql = [
            'CREATE TABLE "new__app_alter_column_a" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "field" varchar(10) NULL);',
            'INSERT INTO "new__app_alter_column_a" ("id", "field") SELECT "id", "field" FROM "app_alter_column_a";',
            'DROP TABLE "app_alter_column_a";',
            'ALTER TABLE "new__app_alter_column_a" RENAME TO "app_alter_column_a";',
        ]
        self.assertValidSql(sql)

    def test_unique_together(self):
        sql = 'CREATE UNIQUE INDEX "app_unique_together_a_int_field_char_field_979ac7d8_uniq" ON "app_unique_together_a" ("int_field", "char_field");'
        self.assertBackwardIncompatibleSql(sql)

        sql = 'DROP INDEX "app_unique_together_a_int_field_char_field_979ac7d8_uniq";'
        self.assertValidSql(sql)

    def test_unique_index(self):
        sql = 'CREATE UNIQUE INDEX "index_name" ON "table" ("col1", "col2");'
        self.assertBackwardIncompatibleSql(sql, "ADD_UNIQUE")


# Path: django_migration_linter/sql_analyser/analyser.py
# def analyse_sql_statements(
#     sql_analyser_class, sql_statements, exclude_migration_tests=None
# ):
#     sql_analyser = sql_analyser_class(exclude_migration_tests)
#     sql_analyser.analyse(sql_statements)
#     return sql_analyser.errors, sql_analyser.ignored, sql_analyser.warnings
# 
# def get_sql_analyser_class(database_vendor, analyser_string=None):
#     if analyser_string:
#         return get_sql_analyser_from_string(analyser_string)
#     return get_sql_analyser_class_from_db_vendor(database_vendor)


# Path: tests/unit/test_sql_analyser.py
import unittest
from django_migration_linter.sql_analyser import (
    analyse_sql_statements,
    get_sql_analyser_class,
)


    def test_alter_column(self):
        sql = [
            'ALTER TABLE "app_alter_column_a" RENAME TO "app_alter_column_a__old";',
            'CREATE TABLE "app_alter_column_a" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "field" varchar(10) NULL);',
            'INSERT INTO "app_alter_column_a" ("id", "field") SELECT "id", "field" FROM "app_alter_column_a__old";',
            'DROP TABLE "app_alter_column_a__old";',
        ]
        self.assertValidSql(sql)

    def test_alter_column_after_django22(self):
        sql = [
            'CREATE TABLE "new__app_alter_column_a" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "field" varchar(10) NULL);',
            'INSERT INTO "new__app_alter_column_a" ("id", "field") SELECT "id", "field" FROM "app_alter_column_a";',
            'DROP TABLE "app_alter_column_a";',
            'ALTER TABLE "new__app_alter_column_a" RENAME TO "app_alter_column_a";',
        ]
        self.assertValidSql(sql)

    def test_unique_together(self):
        sql = 'CREATE UNIQUE INDEX "app_unique_together_a_int_field_char_field_979ac7d8_uniq" ON "app_unique_together_a" ("int_field", "char_field");'
        self.assertBackwardIncompatibleSql(sql)

        sql = 'DROP INDEX "app_unique_together_a_int_field_char_field_979ac7d8_uniq";'
        self.assertValidSql(sql)

    def test_unique_index(self):
        sql = 'CREATE UNIQUE INDEX "index_name" ON "table" ("col1", "col2");'
        self.assertBackwardIncompatibleSql(sql, "ADD_UNIQUE")


        sql = [