DEV Community

Cover image for Bash Script: Knex Database Refresh
Jimmy McBride
Jimmy McBride

Posted on

Bash Script: Knex Database Refresh

Ever get tired of running the same knex commands every time you need to reset your database? Why not just make a bash script that will run them all in one command?

It's super simple and easy

#!/bin/bash

knex migrate:rollback
knex migrate:latest
knex seed:run
Enter fullscreen mode Exit fullscreen mode

I named mine dbrefresh so now anytime I need my database to be reset all I need to do is type dbrefresh inside my terminal and it will rollback, magrate latest and run my seeds in one sweet and easy command.

Thank you very much for reading! Do you have any bash scripts that you use everyday? I've love to see them in the comments below!

Top comments (5)

Collapse
 
pauldparadis profile image
Paul D. Paradis

Thanks for posting this!!! I am interested in learning more about bash. What do you suggest for beginners?

Collapse
 
jimmymcbride profile image
Jimmy McBride

Joe Collins has a great channel. Really love all his bash related stuff. Big Linux guy. youtube.com/watch?v=QlWKQAh7MKc

I also have a few blogs you might be interested in.

Write A Bash Script 101

Where I cover the basics of writing your own bash script.

Bash Alias

Bash alias's are like little mini, one line bash scripts.

Bash Script Tool Kit

I go over some common bash commands I typically find myself using the most and how to use them.

Hope this helps! Thanks for reading.

Collapse
 
pauldparadis profile image
Paul D. Paradis

Thank you very much!!!! I am going to add this information to my Himalayan sized I.T. 'to-do' pile. All joking aside, I am grateful to you for taking the time to reply. Cheers.

Collapse
 
nuwannnz profile image
Nuwan Karunarathna
Collapse
 
pauldparadis profile image
Paul D. Paradis

Thanks!!