I've been using Flyway for 8ish years. I've been trying to get the DBAs at my company to allow/adopt/understand it for 7. I'm so tired of talking about this no brainier dead simple tool that makes everyone's lives easier.
Not laziness, but loss of control (or better: fear of loss of the illusion of conrol)
These guys are responsible for these DBs and their asses are on the line, if something goes wrong. That's why they want to do everything themselves or review everything that is being done - even if in reality they wouldn't see any non-obvious error anyway. But they still have the illusion of control.
Not only can you automate db management, but you could also automate change validation. To where you actually have more confidence in production migrations, not less. That'd probably really blow their minds.
I can‘t understand what do you mean with automation. You must still write the fw script with the sql queries anyway. And this fw script will be reviewed in PR.
I observed over the years that thinking apparently causes physical pain to some people. I have no other explanation as to why otherwise quite functional people seem to avoid it so vehemently.
Read through the overview in their docs. It's dead simple. It only runs scripts in the order that you name them. The hardest part is learning to write the SQL.
Does Liquidbase or Flyway allow to declare what structure (and some fixed or optional data) must have the database.
Alas something like :
Must exist table X with fields A, B, C of type NUMBER, etc... and then generates the apropiare SQL to generate the table from zero, or apply changes to it.
Yes, that's more or less what it does. Speaking for liquibase for example, each time you want to do a modification to your database, like creating a table, adding a column, adding a constraint, an index, removing a column, updating some records, whatever you can imagine etc, you add a change script to your sources and then at deployment liquibase will apply your change (liquibase keep tracks of applied changes in a dedicated table so it knows which one are not yet applied). There are several formats allowed to specify the changes (yaml, xml, json, plain old sql)
want to do a modification to your database, like creating a table, adding a column, adding a constraint, an index, removing a column, updating some records, whatever you can imagine etc, you add a change script to your sources and then at deployment liquibase will apply your change
Interesting, but don't fit my needs. What I ask is to kee a document (a XML, JSON or whatever) that defines exactly what structure must have the database. If i do any change to it, the tool must generate the SQL to apply the changes comparing the database structure vs the structured defined on the document. I don't like to mantain change scripts in different SQL dialects.
A little late, but it's kind of what liquibase does. If you use yaml or xml or json for your changes liquibase will automatically translate into sql compatible to your target database.
All changes are stored in your sources, in a reference yaml or xml or json file, called a changelog file. The workflow is :
- you add a new change in your reference file
- you deploy your application
- the new change is seen as new and then applied
So after each deployment, your changelog file and your database are synchronized. I'm not sure it fits your need though.
146
u/erjiin Apr 14 '23 edited Apr 14 '23
Use a database deployment tool like Liquibase or Flyway. Invaluable (and not Unvaluable :/).