I have a website that I built using Django and deployed on Heroku. The tutorial I followed had me set up a Heroku Postgres database attached as an add-on. After Heroku's recent pricing changes the Postgres database has gone from free to $5 / month.
Maybe static isn't the correct word, but the site doesn't have user accounts, collect user information, or otherwise have any need for a database. I believe the only information that's stored in the database is login info for the Django admin site. I was able to export a .pgdmp file from Heroku of the data stored in the database but couldn't make heads or tails of the contents.
Here's the settings.py
file code for the database section:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
My question is can I delete this add-on from the Heroku CLI or dashboard without breaking the site in production? Would I need to change anything in my settings.py
file or elsewhere in my Django code first? I assume I would still be able to access the Django admin page on the development server, is that assumption correct?
Sorry for the possibly obvious question but I just don't want to break a site in production without doing some research first!
CodePudding user response:
you can check this article on how to delete the postgres add-on on Heroku
By seeing the settings.py code that you have pasted, I don't think your app is configured to use postgres as database, hence your app should still work perfectly fine
But Heroku recommends using postgres as sqlite3 database does not persist on heroku, you can read more on it here
CodePudding user response:
My question is can I delete this add-on from the Heroku CLI or dashboard without breaking the site in production?
We can't know for sure, but probably not.
You are using dj-database-url
to set your default database. That likely means that your application is connecting to PostgreSQL via the DATABASE_URL
environment variable.
SQLite does not work properly on Heroku due to its ephemeral filesystem. If you need a database, it needs to be a client-server database instead of a file-based database.