Reputation: 31
As I know when running $heroku run python manage.py migrate
it creates all tables from models.py. But my output looks different: the table wasn’t created or even mentioned.
Operations to perform:
Apply all migrations: findCharge
Running migrations:
Applying findCharge.0001_initial... OK
Applying findCharge.0002_auto_20161124_1729... OK
Applying findCharge.0003_auto_20161124_1955... OK
Applying findCharge.0004_chargepoints_description... OK
Anyway when I call
$ heroku pg:psql and then ONYX=> \dt
It looks like the table was created and “findCharge_chargepoints” in list of relations.
…
public | findCharge_chargepoints | table | owner_name
…
But when I type
ONYX=> SELECT * FROM findCharge_chargepoints;
ERROR: relation "findcharge_chargepoints" does not exist
I was trying to run “python manage.py migrate” without app name, but result was the same. I run “makemigrations” on my local machine before pushing to git. I also was able to create superuser and I can open https://my-app-name.herokuapp.com/admin and add some data to db, but my app doesn’t see this data.
Any suggestions? I’m sticking in it for 3 days now so I will be grateful for any help.
P.S. I use heroku postgresql hobby-basic with postgis extension.
P.P.S.
database settings from settings.py:
DATABASES = {
'default':{
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'charging_points',
'USER': 'postgres',
'PASSWORD': 'XXX',
}
}
and at the end of the file
import dj_database_url
DATABASES['default'] = dj_database_url.config()
DATABASES['default']['ENGINE'] = "django.contrib.gis.db.backends.postgis"
Upvotes: 1
Views: 1370
Reputation: 2158
Instead of run:
heroku run python manage.py migrate
just run:
heroku run python manage.py migrate --run-syncdb
Upvotes: 0
Reputation: 31
I guess I found the solution or a kind of solution. The table was created but to get access to it I have to use double-quotes:
select * from "findCharge_chargepoints";
I didn't expect it 'cause other tables created by migrate (like auth_user, auth_group etc.) don't need any qoutes at all.
Upvotes: 2