Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There’s nothing stopping you from putting a script to create all of your triggers under version control. With your table and index creation scripts...


How easy is it to deploy those changes then?


We have the DB schema in a custom XML file, and have written a tool to compare the actual schema with that of the XML file. The tool then applies the necessary changes if they're non-destructive (extending column, adding index etc), or fails and lets the user know what needs to be done if run interactively.

By making sure we do as few potentially "destructive" changes to the schema as possible, this tool automatically upgrades our customers database when we release a new version with high reliability.

Adding or altering triggers, stored procs and views are considered "non-destructive" in this context, but of course that requires some discipline from us. One aspect of that is that we try to keep the number of triggers to an absolute minimum. Removing triggers and similar is considered "destructive", however we have a way in the XML to explicitly delete the object if needed.

The XML file lives in our version control repository alongside the source code, and we have triggers which updates test databases automatically when an update is committed etc.

It's a fairly simple idea but has worked quite well for us.


a lot of languages have migrations available, that help manage the state of the database. in addition, postgres allows for you to ALTER or REPLACE functions and triggers, just like you'd ALTER a table.

these in combination make it very easy to manage and deploy.


Liquibase is one example of a tool that integrates with your project and can deploy or rollback version controlled scripts. Bit similar to Rails migrations too from memory.


Not as easy as application code, but easy enough with a good migration tool.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: