title: Django - Rebuild a project database
body: <p>For some reasons, I droped my database by using MYSQL command DROP DATABASE.</p>
  
  <p>I use Python3.6 and Django 1.11 with MySQL database.</p>
  
  <p>So now, how am I supposed to rebuid my database/tables following my models.py ?</p>
  
  <p>I simply used makemigrations but I have some errors like if Django didn't forget any tables.</p>
  
  <pre><code>manage.py makemigrations
  
  File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 292, in query
  _mysql.connection.query(self, query)
  django.db.utils.ProgrammingError: (1146, "Table 'agora.start_games' doesn't exist")
  </code></pre>
  
  <p>For information, 'start' is my only app in my django project. I know this table doesn't exist, I just want to make all rebuilt.</p>
  
  <p>Then, I tried :</p>
  
  <pre><code>root@raspberrypi:/home/django-project/agora# python3.6 manage.py migrate --run-syncdb
  Traceback (most recent call last):
    File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
      return self.cursor.execute(query, args)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
      self.errorhandler(self, exc, value)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
      raise errorvalue
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
      res = self._query(query)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
      rowcount = self._do_query(q)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
      db.query(q)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 292, in query
      _mysql.connection.query(self, query)
  _mysql_exceptions.ProgrammingError: (1146, "Table 'agora.start_games' doesn't exist")
  
  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 "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
      utility.execute()
    File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
      self.check()
    File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
      include_deployment_checks=include_deployment_checks,
    File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
      issues.extend(super(Command, self)._run_checks(**kwargs))
    File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
      return checks.run_checks(**kwargs)
    File "/usr/local/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
      new_errors = check(app_configs=app_configs)
    File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
      return check_resolver(resolver)
    File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
      return check_method()
    File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
      for pattern in self.url_patterns:
    File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
      patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
      return import_module(self.urlconf_name)
    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 950, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 655, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed
    File "/home/django-project/agora/agora/urls.py", line 21, in &lt;module&gt;
      url(r'^start/', include('start.urls')),
    File "/usr/local/lib/python3.6/site-packages/django/conf/urls/__init__.py", line 50, in include
      urlconf_module = import_module(urlconf_module)
    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 950, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 655, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed
    File "/home/django-project/agora/start/urls.py", line 17, in &lt;module&gt;
      from . import views
    File "/home/django-project/agora/start/views.py", line 3, in &lt;module&gt;
      from .forms import MinimumRegisterForm, GamesRegisterForm
    File "/home/django-project/agora/start/forms.py", line 26, in &lt;module&gt;
      class GamesRegisterForm(forms.Form):
    File "/home/django-project/agora/start/forms.py", line 28, in GamesRegisterForm
      for game in Games.objects.all().order_by('title'):
    File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 250, in __iter__
      self._fetch_all()
    File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 1102, in _fetch_all
      self._result_cache = list(self._iterable_class(self))
    File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
      results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
    File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 876, in execute_sql
      cursor.execute(sql, params)
    File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 80, in execute
      return super(CursorDebugWrapper, self).execute(sql, params)
    File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
      six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/usr/local/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
      return self.cursor.execute(sql, params)
    File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
      return self.cursor.execute(query, args)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
      self.errorhandler(self, exc, value)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
      raise errorvalue
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
      res = self._query(query)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 411, in _query
      rowcount = self._do_query(q)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 374, in _do_query
      db.query(q)
    File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 292, in query
      _mysql.connection.query(self, query)
  django.db.utils.ProgrammingError: (1146, "Table 'agora.start_games' doesn't exist")
  </code></pre>