Category: Blog

  • Daily Coping 17 Jun 2021

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag. 

    Today’s tip is to give a complement today to someone outside your family.

    I don’t complement people enough. I should do it more, and this is a good reminder for me to stop and think about what things can I say to people more often. I am getting better with my wife, so that’s something.

    When I saw this, I was on holiday, and I decided to start there. I was with two other couples, and I made it a point to comment when someone had a nice output, or they’d tanned more, or something else. The idea was to focus on enjoying someone else’s positives, which helped me feel more positive.

  • Daily Coping 16 Jun 2021

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag. 

    Today’s tip is to look for something to be thankful for where you least expect it.

    Finding joy, pleasure, growth, learning, and gratefulness in life is important. Looking for it is something that matters for me. I’ve often been a “stop and smell the roses” person, even when I’m busy, to enjoy parts of life. I particularly like this when traveling.

    For me, I got to go on holiday recently. I was lucky and blessed in life. I appreciate that I was able to do this, and I was vaccinated for safety. I hadn’t expected to be in this spot until July or August.

    While I was there, I sat on a beach. It was small (Key West), lots of shells, crowded (relatively) and hot. A little breeze, but not much, and no real amenities for drinks, etc.

    All in all not a great beach experience, but I put that aside. I was grateful that I was able to be on holiday, with my wife and friends, and visit a new place I’d never been to.

    It would have been easy to be annoyed or upset. Easy to complain. A little more challenging to appreciate the experience.

  • A Weekly SQL Clone Image Creation Process

    SQL Clone is a neat product from Redgate that I wish I’d have had when I was doing database software development. It lets me have a consistent image for all developers, and create/reset databases to that starting point in seconds.

    There are two parts to this process: image creation and clone database creation. I’ve written about both in different places, but in this post I want to tackle a weekly image creation process with some tips and recommendations for how to handle this.

    If you want a basic image creation post, read Creating a SQL Clone Agent and a First Image.

    The Goal

    There are a few goals with a weekly image refresh process for database developers:

    • I don’t want to interrupt developers’ work
    • I want consistency that allows other people’s scripts to just run

    In this case, as I create a new image with updated schema and data, I don’t want to require developers to stop working for me to update the image. I also don’t want them to stop while I switch out images. This means I need multiple images for a short period of time.

    The other thing, which wasn’t a recommendation early on, was in naming. Lots of early customers, and us Advocates, were naming images with timestamps or some unique value. However, in an ongoing process, this doesn’t work well.

    This post is the result of some learning, experiments, and feedback from customers.

    The Process Outline

    Rather than start at the beginning of a project, let’s assume we are in an ongoing development process. There is an image, and multiple developers are using this in their cloned databases. For simplicity, let’s say I have this setup:

    • A production database – ADW_Prod
    • Developer Kathi, with a cloned database against ADW_Current – AWD_Kathi
    • Developer Grant, with a cloned database against ADW_Current– AWD_Grant
    • An Image, ADW_Current

    Given all this in use, how do I update ADW_Current with the latest version of production?

    The basic process to follow is this:

    • Create a new image from production, ADW_New
    • Check if there is an ADW_Old image.
      • If so, remove the cloned databases from ADW_Old
      • remove the ADW_Old image
    • Rename ADW_Current to ADW_Old
    • Rename ADW_New to ADW_Current

    That’s it. In an ongoing process, I need image rotation, hence the _New->_Current->_Old. If there isn’t an old image, I skip a couple steps.

    In this process, developers that are using the current image, ADW_Current, are left alone, though they are now using ADW_Old as the image.

    If developers are 2 versions back, on ADW_Old, their databases are dropped. I could deploy new copies of from ADW_Current (or ADW_New), but really, I want developers to be thinking about saving their changes in a VCS often, and not making special little databases they keep for days or weeks.

    Really, I want a developer to finish some work, commit it, and then destroy and recreate their dev database. That’s the whole point of SQL Clone. In about 7sec, I have a new copy of the database. I can then pull everyone else’s changes from VCS and be up to date.

    The Code

    How does this work? Well, I have a single script that I added to a repo on GitHub. I’ll use some images here to show parts, but get the code from there.

    The newimagerotation.ps1 is the script you want. In here, I have some help at the top to give you parameters from PoSh. Then we set some items.I set defaults and then add some standards for my New/Current/Old structure. Feel free to change if that doesn’t make sense to you.

    2021-06-15 18_53_55-buildapisqlclone_newimagerotation.ps1 at main · way0utwest_buildapisqlclone — Mo

    The next part is where I create the New image. If this exists for some reason, like an error, I remove it. Possibly you want to check if there are clones against this and stop, but I never want someone using this.

    2021-06-15 18_55_38-buildapisqlclone_newimagerotation.ps1 at main · way0utwest_buildapisqlclone — Mo

    After this, we want to rename the current image to old. However, if an old image exists, we remove it. Before we can do that, we need to loop through and remove cloned databases. Protection against someone accidentally removing an image, but I am purposefully doing it here.

    2021-06-15 18_56_35-buildapisqlclone_newimagerotation.ps1 at main · way0utwest_buildapisqlclone — Mo

    Once this is done, we rename the new to current, and we’re done.

    2021-06-15 18_57_23-buildapisqlclone_newimagerotation.ps1 at main · way0utwest_buildapisqlclone — Mo

    Summary

    This is an easy process to follow weekly, and it rotates your image so that if people are using scripts or the GUI, they always know to use the _Current image to create a new database.

    This also gives developers a grace period that equals your image refresh process for using an old image. If you run this daily, they can use an image for 2 days. If you run it weekly, they can use it for two weeks.

    If you want to warn them, add a call in the “rename current to old” section to send a message to developers that there are databases that will be removed when the next image is created.

    If you haven’t tried SQL Clone , download an eval and give it a try today. It’s a great way to speed up developer’s experimentation and ensure consistency in dev and test environments.

  • Daily Coping 15 Jun 2021

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag. 

    Today’s tip is to take a light-hearted approach to today. See the funny side.

    One of the annoying things that’s happened lately for me is with an author. This individual submitted a few articles, and I gave them feedback for the articles. I got my feedback removed and the original article submitted. I repeated this, thinking they had edited some items (some time passed), and also changed a title. The author repeated.

    I deleted the articles. The author resubmitted them. This repeated a few times, including me deleting the user account. This continues to this day, albeit with more effort by the author (new accounts), since we’ve added tooling. The author does not respond to emails.

    This was annoying and a time sink for me. After a few weeks, I vented on Twitter one day, mostly curious to see if I was acting poorly. The comments I got let me know this wasn’t the case, but this also helped me appreciate this in a more humorous manner. I could laugh at some of the issues and see this as some sort of game.

    It’s the best I can do, but at least I can see a funny side here. I have no idea what the author’s goal is and don’t care at this point. I’m chuckling at my desk most days.