September 30, 2022

DBIx::Class::DeploymentHandler: why ::Draft

I already posted about how to DeploymentHandler, and I specifically said I would not explain why in that post. This is the why post. TL;DR Much like recipes, I find it very tiresome when a blog post spends all its time justifying its existence instead of answering the topic. Here, then, is why I would advocate for DBIx::Class::DeploymentHandler. You only make your changes once You write those changes in Perl, not in SQL Your code and database are guaranteed to agree1 You make changes in code first, and actually deploy the database when you’re happy with it Of course, you can un-deploy and re-deploy in development as much as you like until you have something you like You have complete freedom over your result classes As opposed to changing the schema and then importing it into code, where you can’t update any of the auto-generated stuff You have complete freedom over the migrations You can edit the SQL that DH creates and it won’t notice You can add extra SQL files and even Perl scripts to be run as part of the same migration Deployment is handled by the same config file that connects your schema in the first place Or not, if you want to restrict the app’s user so it doesn’t have permission to do schema changes You can trivially automate the upgrading of your schema as part of your application’s startup You have a sequential schema version system2 Note, of course, that it only actually works if you are using DBIx::Class in the first place: but this thought leads onto the observation that any ORM in any language could be coerced into outputting the YAML format that DH uses. Read more

July 28, 2022

DBIx::Class::DeploymentHandler: an 80% howto

This post is about how to use DBIx::Class::DeploymentHandler most of the time. It does not explain why you should do it this way; if you need to know that, I’m sure I will write that post at some point as well. This module turns your existing DBIx::Class data model into either deployment scripts, or migration scripts, or both1. It does this by turning the data model into an interim data structure, which is then serialised to YAML and committed to source control. Read more

© Altreus 2020

Powered by Hugo & Kiss.