Skip to content

Commit

Permalink
Merge pull request #2425 from ploxiln/migrate_fake_initial
Browse files Browse the repository at this point in the history
docs: for sql db migration to 1.1 recommend --fake-initial
  • Loading branch information
deniszh authored Feb 19, 2019
2 parents 7ce7893 + e32a4ca commit 928affa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion docs/config-database-setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ To set up a new database and create the initial schema, run:

.. code-block:: none
PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings
.. note ::
Graphite-Web 1.0 and earlier had some models without migrations, and with Django 1.9 or later, the ``--run-syncdb`` option was needed for migrate to create tables for these models. (Django 1.8 and earlier did not have this option, but always exhibited this behavior.) In Graphite-Web 1.1 and later all models have migrations, so ``--run-syncdb`` is no longer needed. If upgrading a database created by Graphite-Web 1.0 or earlier, you need to use the ``--fake-initial`` option for migrate: it considers an initial migration to already be applied if the tables it creates already exist.
If you are experiencing problems, uncomment the following line in /opt/graphite/webapp/graphite/local_settings.py:

Expand Down
2 changes: 1 addition & 1 deletion docs/config-local-settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ The following configures the Django database settings. Graphite uses the databas
See the `Django documentation <https://docs.djangoproject.com/en/dev/ref/settings/#databases>`_ for full documentation of the DATABASES setting.

.. note ::
Remember, setting up a new database requires running ``PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb`` to create the initial schema.
Remember, setting up a new database requires running ``PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings`` to create the initial schema.
.. note ::
If you are using a custom database backend (other than SQLite) you must first create a $GRAPHITE_ROOT/webapp/graphite/local_settings.py file that overrides the database related settings from settings.py. Use $GRAPHITE_ROOT/webapp/graphite/local_settings.py.example as a template.
Expand Down
4 changes: 3 additions & 1 deletion docs/releases/1_1_1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ If you're not already running from the *master* branch, Graphite-Web's applicati
sudo cp /opt/graphite/storage/graphite.db \
/opt/graphite/storage/graphite.db.backup-`date +%Y%m%d_%H%M%S`
sudo PYTHONPATH=/opt/graphite/webapp django-admin.py migrate \
--noinput --settings=graphite.settings --run-syncdb
--noinput --settings=graphite.settings --fake-initial
In this release of Graphite-Web, migrations have been added for any Django models that did not have them. Previously, if using Django 1.9 or later, one needed the ``--run-syncdb`` option for migrate to create tables for Graphite-Web models without migrations (and Django 1.8 or earlier did not have this option but always exhibited this behavior). Django keeps track of which migrations have been applied and attempts to run any that have not, and these new initial migrations try to create tables that already exist from previous versions of Graphite-Web, and fail. This common Django situation is resolved by the ``--fake-initial`` option for migrate: it considers an initial migration to already be applied if the tables it creates already exist.


Other Changes
Expand Down

0 comments on commit 928affa

Please sign in to comment.