Tag: Flyway

  • Friday Flyway Tips–Linking Commits to an Azure DevOps Work Item

    Recently I was doing a demo and a customer asked how I had linked my commit in Azure DevOps to the work item that existed. It’s easy, and tldr; it’s with the commit comment. This post shows how that works.

    I’ve been working with Flyway Desktop for work more and more as we transition from older SSMS plugins to the standalone tool. This series looks at some tips I’ve gotten along the way.

    Creating a Work Item

    In Azure DevOps, there is a board menu. Under here, one of the subitems is Work Items. You can see these below:

    2023-12-13 17_52_28-Work items - Boards

    I tend to work from the “Boards” item, which looks like this:

    2023-12-13 17_52_22-Westwind Team Features Board - Boards

    Let’s assume we have a new item, so I’ll click the “New Item” at the top of the left column. This gives me an edit box, which I’ll type in a name.

    2023-12-13 17_54_25-Westwind Team Features Board - Boards

    When I hit enter, this gives me a new work item, which you see below, as 250 create products entitty.

    2023-12-13 17_55_19-Westwind Team Features Board - Boards

    Since I don’t want to leave a spelling error, I’ll edit the title to look better.  Now I have a work item.

    Linking A Commit in FWD

    In SSMS, I’ll create the products table. Once I do this, I’ll go to Flyway Desktop and refresh the schema model. When I do this, I see my change. I’ll select this and save to the file system.

    2023-12-13 18_01_48-Flyway Desktop

    Once this is done, I’ll go to the Version Control tab, and I again see my file changed. Here my file is selected, and I’ll enter a commit message, but I’ll include the work item number after a #. This creates a link.

    2023-12-13 18_02_45-Flyway Desktop

    I now click commit and push. In Azure DevOps, in the Repos –> Commit item, I see my commit.

    2023-12-13 18_04_15-Commit 1421f994_ #250 create products table - Repos
    Note the details item under my cursor. If I click that, I see commit details and near the bottom, a link to the work item.

    2023-12-13 18_04_21-Commit 1421f994_ #250 create products table - Repos

    If I click through to the work item, or I access the work item from Boards, I will see my commit linked on the far right of the work item.

    2023-12-13 18_04_32-Westwind Team Features Board - Boards

    This is very handy to have your actual code linked to the work that it relates to. If I have PRs or multiple commits, as long as you use the #nnn, where nnn is the work item, you’ll have everything linked together.

    This is less a Flyway Desktop feature than an Azure DevOps one, but you can access this from Flyway Desktop by writing good commit messages with work item numbers.

    Try Flyway Desktop out today. If you haven’t worked with Flyway Desktop, download it today. There is a free version that organizes migrations and paid versions with many more features.

    Video Walkthrough

    I made a quick video showing this as well. You can watch it below, or check out all the Flyway videos I’ve added:

     

  • Friday Flyway Tips–Above Target Migrations

    Recently I was working with Flyway Desktop (FWD) and practicing deploying certain migrations and not others. I don’t recommend this, but a customer was doing this and I wanted to reproduce some things they were trying to help them.

    In doing this I discovered a bunch of scripts marked as “Above Target” in the GUI, but not in the database. I learned a few things from our support team.

    I’ve been working with Flyway Desktop for work more and more as we transition from older SSMS plugins to the standalone tool. This series looks at some tips I’ve gotten along the way.

    Setting a Target

    I’ve got a FWD project here, and you can see the migrations below. In this case, I’ve selected a target of my QA machine and we can see that I have migrations applied up to 3.1 and there are pending migrations from 4-8 (ignore the undo).

    2023-12-05 14_07_37-Flyway Desktop

    Now, I want to migrate QA, but only to version 5. When I do this, from “Advanced Settings” on the right, I’ll see the target is listed as a parameter, and if I’ve highlighted the parameter on in the script.

    2023-12-05 14_10_13-Flyway Desktop

    I’ll run migrate, which works.

    2023-12-05 14_12_58-Flyway Desktop

    When I close this, I now see a different view. I see success next to migrations 4 and 5, but I also now see “above target” listed for the other migrations.

    2023-12-05 14_13_14-Flyway Desktop

    That’s not great, for this reason. If I check the “only show pending migrations”, I lose all my migrations. In large, complex projects, this isn’t good.

    2023-12-05 14_14_55-Flyway Desktop

    Getting Pending Migrations Back

    The easy solution to this is to remove the target. If I click the “x” on the target parameters…

    2023-12-05 14_15_50-Flyway Desktop

    And then click Refresh at the top, I now see my migrations as pending.

    2023-12-05 14_16_00-Flyway Desktop

    Seems obvious, but I’d forgotten about the target as I was focused on testing the code I’d released and then wanted to release other code. Peter in support educated me on what I was missing.

    Try it out today. If you haven’t worked with Flyway Desktop, download it today. There is a free version that organizes migrations and paid versions with many more features.

    Video Walkthrough

    I made a quick video showing this as well. You can watch it below, or check out all the Flyway videos I’ve added:

     

  • Migrations are Worth the Effort

    I work with a lot of customers that are trying to find better ways to build and deploy database code. Some of them use a state or model method with SQL Compare or another Redgate product, and some want to use Flyway and its hybrid migration-based framework. It’s always interesting to me how customers lean one way or the other, for various reasons.

    No matter which choice people make, we know that using migrations is more effort than a state-based approach. However, I think that it’s a better approach, especially because no matter how simple or smooth you think your development process is, at some time there will be a situation that needs a more complex approach. a migrations-based framework allows you to handle the complexity smoothly, without depending on a person to sort out the issues.

    It’s not just me, but many developers feel the same way. There’s an interesting article from a developer that gives some examples of why using migrations work well in different situations. It also acknowledges that the effort is high, but by using migrations you can accomplish complex tasks across time. something I try to get more developers to do. Don’t big-bang-deploy-everything, but break things into chunks.

    It’s not just a simple change. There are a few reasons that migrations are hard, one of which I loved. The author compares migrations to working with live electrical wires. Imagine hanging a ceiling lamp and wiring it up without turning off the power (note: don’t try that).

    One of the best reasons I have for migrations is that lots of work isn’t done at the same time, especially in a team. If each team or each piece of work is broken into separate migrations, choosing which ones to move over from developer is much easier than if all the changes are captured in a state-ful model. You still have to be aware of dependencies between migrations, but having them all separate at the beginning (and hopefully tagged to pieces of work) makes this easier.

    The other reason to choose migrations is that I can stage future changes. Imagine I need to make a change to add something in one migration and remove it later. Suppose we add a new tax column and then after Jan 1, we remove the old tax column. With migrations I can pre-write the removal and create a pull request with the “Tax Removal – DO NOT MERGE UNTIL 2024 JAN 1” title, which should be obvious to anyone. I like keeping things simple, which helps when I never know who might need to handle this work in the future.

    Steve Jones

    Listen to the podcast at Libsyn, Spotify, or iTunes.

  • Friday Flyway Tips–Deploying Migrations with a Target

    Recently I was working with Flyway Desktop (FWD) and helping a customer work on deploying part of their work. They weren’t sure how easy this could be, but this post follows what I showed them.

    Using the ability to run Flyway commands in FWD, we can deploy some migrations and not others. This post shows how to configure this.

    I’ve been working with Flyway Desktop for work more and more as we transition from older SSMS plugins to the standalone tool. This series looks at some tips I’ve gotten along the way.

    Picking Migrations

    I’ve got a FWD project here, and you can see the migrations below. In this case, I’ve selected a target of my QA machine and we can see that I have migrations applied up to 5 and there are pending migrations from 6-8 (ignore the undo).

    2023-12-05 15_07_27-Flyway Desktop

    If I want to apply migration 6, but not 8, I can do that. First, I’ll click the Advanced settings on the right side. When I do that, I see text with a “add parameters” button.

    2023-12-05 15_08_15-Flyway Desktop

    If I click the Add parameters button, I get a drop down that is searchable.

    2023-12-05 15_08_58-Flyway Desktop

    I can start typing “ta” in here and you see matching items. “Target” is the last one and this is the parameter that you want.

    2023-12-05 15_09_06-Flyway Desktop

    The value of the target is the last migration you want to run. In this case, I can pick 6 and it will run only migration 6. If I pick 7, it will run 6 and 7.

    2023-12-05 15_09_15-Flyway Desktop

    Once I do this, I can click back (or add more parameters) and on the main screen I see that target is in blue, as a parameter added. In the command text box, I’ve highlighted this command as added to the CLI.

    Note: This text is what you could run in a CI system or at a cmd/shell .prompt

    2023-12-05 15_09_38-Flyway Desktop

    When I click migrate, the command is run and I get output about which migrations ran.

    2023-12-05 15_12_16-Flyway Desktop

    If I close this, then I see 6 is successfully applied (after unchecking only show pending) and 7 and 8 are above target. In another post, I’ll explain those.

    Try Flyway Desktop out today. If you haven’t worked with Flyway Desktop, download it today. There is a free version that organizes migrations and paid versions with many more features.

    Video Walkthrough

    I made a quick video showing this as well. You can watch it below, or check out all the Flyway videos I’ve added: