Makemigrations highlighter, Interesting or Noise?

@AMK9978 I like the idea. A little bit of colour and -/+ signs would make the output more readable and could highlight accidental removals.

I am not entirely sold on the safe/possibly destructive/destructive categorization, at least the names. Even adding a table may be “unsafe” and crash, if your database user doesn’t have permissions to create tables.

I would prefer to stick with only “add“ and “remove” categories. The +/- could then be read more like a diff.

I would always count a RenameField as destructive, since it removes the old name, preventing any currently running deployment from using the name it relied on. Also, it’s probably best to always count RunSQL as destructive, because a yellow “possibly destructive“ highlight could be easily ignored.

I’m afraid that is likely impossible in general. It will depend on the database backend, version, storage engine, configuration, and many other features outside of Django’s control. To grab that information it’s probably best to actually run the migration against a real database server, such as on a dev or staging environment, and inspect the locks held.