When I'm fixing a bug during web development projects, I often find myself cleaning out the existing (tainted) database records, clearing out log files, etc.
I do this so that I can start from a fresh state to ensure that none of the previous buggy run's records will affect my new run.
Dropping tables, clearing log files and caches, etc. get pretty tedious to do everytime the server is restarted, so right now I have a simple shell script that I run called
drop.sh that automates that process. It looks something like:
#!/bin/bash mongo <dbname> --eval "db.dropDatabase()" cd /project/directory rm ./logfile1.log touch logfile1.log rm ./logfile2.log touch logfile2.log
But I feel this is very clunky and also not sure whether to include this script in the
I'm a new developer who has no real world experience yet (student). I'm guessing that this isn't what's actually done in industry, and wanted to ask what the best practice is to automate something like this.
Should I be using a
Makefile instead that can clear out the server state?
Should I be using automated build software like Jenkins or something?
In case it matters, the two projects I'm working on right now that deals with this issue is:
- A python script that works with MongoDB database
- A Node.js + Express server + PostgreSQL database for a full-stack webapp