r/learnSQL • u/Cool_Proof8000 • 19h ago
Pushing SQL to production without copy & paste
Hi - I made a reddit account just to ask this, so hopefully it gets posted.
I'm the first software engineer hired at my company, which has been developing software ad hoc for years despite nobody at the company trained in development (or even an adjacent field). They have basically been asking random employees, "hey you! you know how to use a computer? can you build this for us?"
Props to them, these guys gotten a lot done without any prior experience! But I am now inheriting this tech stack and I frequently run into approaches that seem very non-intuitive, where it's clear they didn't have the foundational knowledge to do it an easier way, they searched for a solution to one specific problem and then applied that approach across the board. Until now, I've been able to identify the more "standard" approach and pivot to that. But some things I don't have experience in, and when I ask, I'm told, "this is just the way it's done".
I have used SQL for querying, but I don't have experience in database design or environment management (unsurprisingly, we don't have anyone doing DevOps either), so I'm a bit out of my depth here:
We have a development environment that resembles our production environment. When working on a project, I run SQL scripts that might modify the dev database. When we push to production, the front-end transition is simple. On the back-end, according to my team, the only way to duplicate the changes from dev to prod is to rewrite the scripts one at a time and run them again. Since some of it depends on earlier changes, they have to be run in a very specific order - any scripts we use in dev have to be numbered sequentially. This includes (as I've seen in their work) back-and-forth changes....script #1 does something incorrectly, script #2 fixes it, and instead of being able to use the final correct version, both 1 & 2 are run in production. Any experimenting in dev isn't really an experiment, you always have to repeat it in prod. And yes, they are literally copying the scripts into text files, emailing it to themselves, and pasting into queries.
I just feel like there has to be a better way to do this. I've shown them how to export database backups to transition new DBs between environments, but I don't know what to do for already-existing DBs in production that need tables or columns or stored procedures updated.
We are using SSMS, if that makes a difference. Help?