I know that the file db.sqlite3 in Django holds the entire database and the entire content within it. Is it safe to keep all the project files, the *.py files, the migrations files, but replace the db.sqlite3 file with a different one. If both these db.sqlite3 files work on the same database model, with the same tables, rows, columns, and everything, then if I swap out that file it should work seamlessly.
I want to copy the original db.sqlite3 file into a different directory. Then I want to create a new db.sqlite3 file in my project. Then I want to work with the new database file, and give it other data to test how the project would work with it. Then I want to delete the new db.sqlite3 file, and I want to restore the old one, which I've saved into another directory.
Would that work? And how can I create a new db.sqlite3 file, a clean state to put test data into?
Also, what if I build my project on another sever, can I copy my old db.sqlite3 file there too, and have the database with all it's saved data restored?
Basically, the main idea of my question is: are we to treat the db.sqlite3 file as a simple "text file" with input/output data for our program, something that is freely interchangeable?
Yes, whole sqlite database is contained in one file, so you can freely move, replace, push it with django project (althought it's not recommended) and it will work fine.
Even if you have 2 different projects with same apps, same model structure and migrations, you can swap them.
If you remove your db.sqlite3 and want to create new one, just run python manage.py migrate and it will create new database and apply all migrations.
Can I arbitrarily replace and restore the db.sqlite3 file?