0

I have deployed a Django App like 3 months ago and i was able to migrate changes easily on the heroku bash. Right now i'm trying this:

heroku run python manage.py migrate

Also tried this:

heroku run python manage.py migrate --no-input

And i tried accesing to the heroku bash like this:

heroku run bash

And then run:

~ $ python manage.py migrate

All this commands seems to work: https://i.stack.imgur.com/JWW6S.png

But they don't. When i tried to migrate again, i thought it would show me the typical No migrations to apply.. But this is not the case

¿What should i do to migrate changes?

Matias Coco
  • 351
  • 3
  • 9
  • What database are you using? Sqlite? – Marcus Aldrey Oct 14 '21 at 00:24
  • @MarcusAldrey Yes – Matias Coco Oct 14 '21 at 01:23
  • Could you please share some more details, what are you able to see on the console, do you able to see the data / tables in the DB. when you run your application do you able to see new migrated tables or not ? did you try to run the same migration locally ? Django version on heroku vs local ? – Shreeyansh Jain Oct 14 '21 at 01:44
  • @ShreeyanshJain I tried to type ```python manage.py shell``` so i can see if the tables where added, but they don't. I think it is becouse of what @MarcusAldrey said in the answers. Heroku remove inmediately the migration changes. And yes, i deployed the app on pythonanywhere and it works perfectly. The problem is only on Heroku. – Matias Coco Oct 14 '21 at 13:16

1 Answers1

0

If you are using SQlite, the migration changes on Heroku are applied and removed immediately. You have to use Heroku Postgres add-on (check on the your project overview if it's already installed) and add this to your settings.py

if "DATABASE_URL" in os.environ:
    import dj_database_url

    DATABASES = {"default": dj_database_url.config()}

you can also add this to your Procfile to migrate on deploy

release: python manage.py migrate
  • I already added the **release** in the **Procfile**. I want to test that change on **settings.py** but i'm using pythonanywhere and there, this django app works as expected. It may change the behavior and i only want to use heroku to test things and pythonanywhere for production deployment. – Matias Coco Oct 14 '21 at 13:13