Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix query, ensure that we only check tables in the right schema
If we don't use this `where` this query returns the tables from all the schemas and not just the schema we are looking for. Filter applied in the `left join` does not have the expected result in this scenario. Just run the query below and you see what I mean ```sql SELECT TABLE_NAME, i.TABLE_SCHEMA, TABLE_TYPE, CAST(ep.value AS VARCHAR) AS COMMENT FROM INFORMATION_SCHEMA.TABLES i LEFT JOIN sys.tables t ON t.name = i.TABLE_NAME LEFT JOIN sys.extended_properties ep ON t.object_id = ep.major_id AND ((ep.name = 'MS_DESCRIPTION' AND ep.minor_id = 0) OR ep.value IS NULL) AND i.TABLE_SCHEMA = 'my_dev_schema' ``` If we have in the same database one schema the has the django_migrations but we are then running our application, that does not have migrations, against a different schema, this bit here breaks the application. The function has_table() will return True, but it should return False, because out schema does NOT have the table.
- Loading branch information