How Manage Scripts Applied to the Database
Ey pals, have you ever had the situation where you need to write a script for to perform some kind of operation over the database.
- Alter a column and add a new colum.
- Replace all strings from a column with a new string.
- Excute a list of scripts to follow most updated changes on a database.
Although the application doesn’t support a migrations. Like Prisma, Django, Rails and others.
Therefore you are not able to execute
And it’s a struggle to have control over which scripts were executed and which ones were not.
On my work we have a list of scripts like:
I need to know which scripts where applied to the DB and which didn’t.
For that I had created
It’s a little python script to record which scripts were applied.
ctrls Usage: ctrls [OPTIONS] COMMAND [ARGS]... 🎛️ Ctrl-S - control scripts applied by zodman Options: --help Show this message and exit. Commands: add add-dir status
With the command
add It store in a table called
__ctrl_scripts_applied all scripts applied.
status which ones didn’t.
This help me alot because my coworkers can create scripts and I can check which script I have locally missed.
the script is here: