title: Define unique constraint for PostgreSQL deployment
body: <p>I am trying to deploy to Heroku and converting from sqlite3 to postgres. </p>
  
  <p>A given Showtime refers to a Film and a Venue. </p>
  
  <p>I think I'm just missing some kind of declaration for the model setup that designates the foreign key fields as unique.  </p>
  
  <p>When I run make migrations I get the following error. T</p>
  
  <pre><code>  Applying venues.0018_auto_20170824_1907...Traceback (most recent call last):
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
  psycopg2.ProgrammingError: there is no unique constraint matching given keys for referenced table "venues_venue"
  
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    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 363, in execute_from_c
  ommand_line
      utility.execute()
    File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, 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_for
  wards
      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 244, in apply_migration
      state = migration.apply(state, schema_editor)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/migration.py", line 129, in apply
      operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 216, in databas
  e_forwards
      schema_editor.alter_field(from_model, from_field, to_field)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 515, in alter_field
      old_db_params, new_db_params, strict)
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/schema.py", line 112, in _alter_fi
  eld
      new_db_params, strict,
    File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 773, in _alter_field
      self.execute(self._create_fk_sql(model, new_field, "_fk_%(to_table)s_%(to_column)s"))
    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: there is no unique constraint matching given keys for referenced table "venues_venue"
  
  
  
  class Venue(models.Model):
  name            = models.CharField(max_length=40, null=False, blank=False)
  venue_id        = models.SmallIntegerField(unique=True, null=False, blank=False)
  
  class Film(models.Model):
      title           = models.CharField(max_length=256, null=False, blank=False)
      film_id         = models.SmallIntegerField(unique=True, null=False, blank=False)
  
  class Showtime(models.Model):
  showtime_id     = models.SmallIntegerField(null=True, blank=True)
  venue_id        = models.ForeignKey(Venue, to_field="venue_id", db_column="venue_id")
  film_id         = models.ForeignKey(Film, to_field="film_id", db_column="film_id")
  </code></pre>