556
edits
Line 34: | Line 34: | ||
* Boxes shouldn't be deleted from the database, nor should the owner_id column be set to NULL, as this could result in the loss of useful information such as who owned the box last. Instead, boxes can be marked as inactive or unowned. | * Boxes shouldn't be deleted from the database, nor should the owner_id column be set to NULL, as this could result in the loss of useful information such as who owned the box last. Instead, boxes can be marked as inactive or unowned. | ||
* Created migration scripts to upgrade and downgrade any database changes. The benefit of this is it makes it easy to seed the database with valid locations while minimising the risk of the changes causing a problem to the live database through a failed action (the migration is transactional so an error will cause it to rollback to the previous stable state and not leave it in a horrible half migrated mess) | * Created migration scripts to upgrade and downgrade any database changes. The benefit of this is it makes it easy to seed the database with valid locations while minimising the risk of the changes causing a problem to the live database through a failed action (the migration is transactional so an error will cause it to rollback to the previous stable state and not leave it in a horrible half migrated mess) | ||
* Access database | |||
sqlite3 var/database.db | |||
* Upgrade migration | |||
sqlite3 var/database.db < etc/migrations/0001_upgrade.sql | |||
* Downgrade migration | |||
sqlite3 var/database.db < etc/migrations/0001_downgrade.sql | |||
=== Database Design === | === Database Design === |