tethysplatform / tethys

The Tethys Platform main Django website project repository.
http://tethysplatform.org/
BSD 2-Clause "Simplified" License
92 stars 49 forks source link

Make sqlite default db #928

Closed sdc50 closed 1 year ago

sdc50 commented 1 year ago

Changes the default database configuration in settings to use SQLite instead of Postgres.

Provides backwards compatibility code to detect if a default Postgres database was already configured to preserves the postgresql engine in that case.

coveralls commented 1 year ago

Coverage Status

Coverage: 100.0%. Remained the same when pulling 6832aa7a1ed6707342eb1d08cd7c901a360361e8 on make_sqlite_default_db into 505282b624607f1303d6cdac7408578ef6c345aa on main.

swainn commented 1 year ago

@sdc50 can you rebase this now that the other one is merged?

sdc50 commented 1 year ago

Remaining work for this PR:

see: https://github.com/tethysplatform/tethys/issues/925#issuecomment-1450384795

sdc50 commented 1 year ago

Add data migration command/instructions to switch from one type of DB to another

I'm not sure about this one. I played around with the Django dumpdata and loaddata commands. It takes a little fingagling, and only worked for simple cases. I may provide some instructions to repeat what I did with the caveat that it likely won't work smoothly.

sdc50 commented 1 year ago

@swainn I think this is ready to go. As for the production documentation I think that it is out of scope to write a detailed guide for setting up other types of databases, and if we ever did I would want to throughly test them in a production environment first. What I did include is an explanation that other database backends are possible and referred to the Django Database docs for more details.

sdc50 commented 1 year ago

Also, it looks like the most recent version of python-social-auth was breaking our tests. As far as I can tell it just dropped support for a very outdated way of using middleware, but our tests were still calling it with the old style (not passing in a get_request argument).

swainn commented 1 year ago

Also, it looks like the most recent version of python-social-auth was breaking our tests. As far as I can tell it just dropped support for a very outdated way of using middleware, but our tests were still calling it with the old style (not passing in a get_request argument).

Is it only our tests that are using the old way? Is the code up-to-date?

sdc50 commented 1 year ago

Do we need to add sqlite3 to the environment.yml? Are we planning to take out the postgresql dependencies and add instructions for installing them when you want to use postgresql?

sqlite3 is native to Python so no dependencies needed. I wasn't planning to remove the PostgreSQL dependencies. I think they are still handy to have available to test production environments.

sdc50 commented 1 year ago

Is it only our tests that are using the old way? Is the code up-to-date?

The TethysSocialAuthExceptionMiddleware class is never actually instantiated in our code. It's added as a middleware, so I think it's only instantiated by Django.