ableinc / laprune

Run delete queries on one or more databases in a given environment. This is useful for delete test account records for users.

Repository from Github https://github.comableinc/lapruneRepository from Github https://github.comableinc/laprune

laprune

Run delete queries on one or more databases in a given environment. This is useful for delete test account records for users.

How to run

go build -o laprune main.go
touch db.json queries.sql
vim db.json # use db.example.json as reference
vim queries.sql # use config/queries.example.sql as reference
./laprune /path/to/db.json /path/to/queries.sql

Command Line Arguments

  1. ping - Test the database connection

Usage:

./laprune db.json config/queries.sql ping

db.json Environments

The valid environment types are:

test
development
staging
production

Setup on server

Install cron

sudo apt-get update
sudo apt-get install cron

Start cron

sudo systemctl start cron

Update permissions for executable

chmod +x /path/to/laprune

Open crontab file for editing

crontab -e

Add cronjob

* * * * * /path/to/laprune

Example of running executable everyday at 1am

0 1 * * * /path/to/laprune

Verify cronjob

crontab -l

Notes

  1. The script requires you pass both db.json and queries.sql file paths. You can provide the directories to each and the program will append the file names to the end and validate if the files exist.
  2. "ping" argument does not work for MongoDB connections.

About

Run delete queries on one or more databases in a given environment. This is useful for delete test account records for users.


Languages

Language:Go 100.0%