0

Every time I change columns name or length or anything, I need to drop the entire database in heroku. This is after doing makemigrations and migrate. On local, it works fine. I don't need to adjust. On heroku it's becoming to a point where I can't keep resetting. I reset by using heroku pg:reset DATABASE_URL.

What is another way where I don't need to drop the entire database every single time i make an adjustment?

[[edit]]

DATABASES = {
    "default": {
        # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
        "ENGINE": "django.db.backends.postgresql",
        # DB name or path to database file if using sqlite3.
        "NAME": "name",
        # Not used with sqlite3.
        "USER": "uesrname",
        # Not used with sqlite3.
        "PASSWORD": "password",
        # Set to empty string for localhost. Not used with sqlite3.
        "HOST": "xxxxxxxxxx.compute-1.amazonaws.com",
        # Set to empty string for default. Not used with sqlite3.
        "PORT": "5432",
    }
}
hammies
  • 1,344
  • 2
  • 22
  • 46
  • The whole point of migrations is that they make incremental changes to your database so you don't need to drop it. Just run the migrations. – Daniel Roseman Sep 25 '17 at 19:24

1 Answers1

0

You need to commit the generated migration files, push to Heroku, and run the migrations via heroku run python manage.py migrate.

bimsapi
  • 4,985
  • 2
  • 19
  • 27
  • it's not working. It's not updating the tables, getting error - missing tables on my pages. – hammies Sep 27 '17 at 18:53
  • Can you post 1) the error message you are receiving and 2) the contents of your settings file? – bimsapi Sep 27 '17 at 19:22
  • is there a particular section u are looking for in settings file? Not sure if I want to post everything... The error message is simply, app_table doesn't exists. When I drop everything, no error. And it's becoming tolling. – hammies Sep 27 '17 at 19:28
  • the other thing is that local is fine. this only happens when i push to heroku – hammies Sep 27 '17 at 19:29
  • Database connection settings (minus any passwords). "Table missing" (obviously) means migrations aren't running. Understanding how you are connecting may shed light on why. – bimsapi Sep 27 '17 at 19:36
  • I updated the db info in the post. Im pretty much following the 1-7 steps here. https://stackoverflow.com/questions/28598676/django-heroku-error-your-models-have-changes-that-are-not-yet-reflected-in-a-mi Maybe I need to redo everything? – hammies Sep 27 '17 at 19:41
  • Thanks for the edit. It's not clear that you are following this: https://devcenter.heroku.com/articles/django-app-configuration#database-configuration The key is that all of the db information is in that environment variable; user, pass, port, etc. and the – bimsapi Sep 27 '17 at 21:34
  • I probably read that like 20x. At this point, I am just repeating everything I read/did. I think I am going to drop the table and redo, worse thing to do, I know. Thanks though! – hammies Sep 27 '17 at 21:39