Closed hiagomeels closed 2 years ago
Should each of these full file detections checker live in their own modules? I think breaking it down into multiple modules will also be more readable and testable. Any thoughts?
One more thing – index_concurrently_without_disable_ddl_transaction
and index_concurrently_without_disable_migration_lock
should be added to README.md
.
@Artur-Sulej
One more thing –
index_concurrently_without_disable_ddl_transaction
andindex_concurrently_without_disable_migration_lock
should be added toREADME.md
.
I have created this PR to do it.
8
It will add a checker to verify if the following module attributes are set up to true when the migration contains an operation to add or drop an index concurrently.
As said here, the unique way that I found to include this feature was going through the entire code_ast.
AstParserFullDetections
)detect_invalid_index_concurrently
validationThe checker consists of post-walk with the AST and checking:
If some of the operations are adding a concurrent index
true
defp detect_invalid_index_concurrently_inner(disable_migrationlock, , [true]} = ast_part, acc) do {ast_part, %{acc | has_lock?: true}} end
For now, I have named these news danger types
index_concurrently_without_disable_ddl_transaction
andindex_concurrently_without_disable_migration_lock,
but I'm not sure which will be a more appropriate name for them.Let me know your thoughts on that.