I added a new permission to my model, and than used manage.py makemigrations. it created a migration that alters the model options (specificly the permisions..).
later , I added a migration that has a dependency on that first migration, and uses the permission (that i believed the first migration created). that migration used the permission in a RunSQL operation that queried auth_permissions.
as i debugged the migrations - i realized that the insert to the auth permission only happens after all of the migrations have been applied.
meaning - when i try to query the id of the permission in order to use it in the second migration - it doesn't exist and so the second migration doesn't behave as expected.
any idea why this happens and how to prevent it? my assumption when adding a new permission was that it will be added with the migration that django created for me..and not at a different stage.
Thanks!