diff --git a/tests/functional/test_migration_linter.py b/tests/functional/test_migration_linter.py index 2a3fc55..ef966f1 100644 --- a/tests/functional/test_migration_linter.py +++ b/tests/functional/test_migration_linter.py @@ -85,6 +85,10 @@ class BaseBackwardCompatibilityDetection(object): app = fixtures.ALTER_COLUMN self._test_linter_finds_no_errors(app) + def test_drop_unique_together(self): + app = fixtures.DROP_UNIQUE_TOGETHER + self._test_linter_finds_errors(app) + def test_accept_alter_column_drop_not_null(self): app = fixtures.ALTER_COLUMN_DROP_NOT_NULL self._test_linter_finds_no_errors(app) diff --git a/tests/unit/test_sql_analyser.py b/tests/unit/test_sql_analyser.py index 441d85a..d454c24 100644 --- a/tests/unit/test_sql_analyser.py +++ b/tests/unit/test_sql_analyser.py @@ -62,6 +62,13 @@ class MySqlAnalyserTestCase(SqlAnalyserTestCase): ] self.assertValidSql(sql) + def test_unique_together(self): + sql = "ALTER TABLE `app_unique_together_a` ADD CONSTRAINT `app_unique_together_a_int_field_char_field_979ac7d8_uniq` UNIQUE (`int_field`, `char_field`);" + self.assertBackwardIncompatibleSql(sql) + + sql = "ALTER TABLE `app_unique_together_a` DROP INDEX `app_unique_together_a_int_field_char_field_979ac7d8_uniq`;" + self.assertValidSql(sql) + class SqliteAnalyserTestCase(SqlAnalyserTestCase): database_vendor = "sqlite" @@ -110,6 +117,13 @@ class SqliteAnalyserTestCase(SqlAnalyserTestCase): ] 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) + class PostgresqlAnalyserTestCase(SqlAnalyserTestCase): database_vendor = "postgresql" @@ -129,3 +143,10 @@ class PostgresqlAnalyserTestCase(SqlAnalyserTestCase): def test_drop_not_null(self): sql = 'ALTER TABLE "app_alter_column_drop_not_null_a" ALTER COLUMN "not_null_field" DROP NOT NULL;' self.assertValidSql(sql) + + def test_unique_together(self): + sql = 'ALTER TABLE "app_unique_together_a" ADD CONSTRAINT "app_unique_together_a_int_field_char_field_979ac7d8_uniq" UNIQUE ("int_field", "char_field");' + self.assertBackwardIncompatibleSql(sql) + + sql = 'ALTER TABLE "app_unique_together_a" DROP CONSTRAINT "app_unique_together_a_int_field_char_field_979ac7d8_uniq";' + self.assertValidSql(sql)