title: Permission denied for relation django_migrations using Heroku
body: <p>While attempting to migrate database changes using django on Heroku, I get:</p>
  
  <pre><code>psycopg2.ProgrammingError: permission denied for relation django_migrations
  </code></pre>
  
  <p>Other people have been able to resolve this issue by granting the appropriate privileges (e.g., <a href="https://stackoverflow.com/questions/15520361/permission-denied-for-relation">Permission denied for relation</a>). Unfortunately, I can't grant permissions or create a new user on the Heroku hobby tier.</p>
  
  <p>I was able to roll back a few migrations, but eventually I got:</p>
  
  <pre><code>django.db.utils.ProgrammingError: table "labs_branch_tests" does not exist
  </code></pre>
  
  <p>and could not migrate back to newer migrations.</p>
  
  <hr>
  
  <p>Full traceback for permission denied for relation django_migrations</p>
  
  <pre><code>  File "manage.py", line 22, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
      utility.execute()
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
      output = self.handle(*args, **options)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
      fake_initial=fake_initial,
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate
      state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
      state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 250, in apply_migration
      self.recorder.record_applied(migration.app_label, migration.name)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in record_applied
      self.migration_qs.create(app=app, name=name)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 394, in create
      obj.save(force_insert=True, using=self.db)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 807, in save
      force_update=force_update, update_fields=update_fields)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 837, in save_base
      updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 923, in _save_table
      result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 962, in _do_insert
      using=using, raw=raw)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 1076, in _insert
      return query.get_compiler(using=using).execute_sql(return_id)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1107, in execute_sql
      cursor.execute(sql, params)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
      six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
  django.db.utils.ProgrammingError: permission denied for relation django_migrations
  </code></pre>
  
  <p>Full traceback for psycopg2.ProgrammingError: table "labs_branch_tests" does not exist</p>
  
  <pre><code>  File "manage.py", line 22, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
      utility.execute()
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
      output = self.handle(*args, **options)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
      fake_initial=fake_initial,
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 119, in migrate
      state = self._migrate_all_backwards(plan, full_plan, fake=fake)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 194, in _migrate_all_backwards
      self.unapply_migration(states[migration], migration, fake=fake)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 264, in unapply_migration
      state = migration.unapply(state, schema_editor)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/migration.py", line 178, in unapply
      operation.database_backwards(self.app_label, schema_editor, from_state, to_state)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 95, in database_backwards
      schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 457, in remove_field
      return self.delete_model(field.remote_field.through)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 324, in delete_model
      "table": self.quote_name(model._meta.db_table),
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 120, in execute
      cursor.execute(sql, params)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
      six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
  django.db.utils.ProgrammingError: table "labs_branch_tests" does not exist
  </code></pre>