UUIDv7 in MySQL

Similar to my previous post, this code generates a UUID of the new v7 type, which has a Unix-timestamp base. This keeps UUIDs sortable by creation-date, which is useful when using them as database keys, for example

SELECT LOWER(CONCAT(
	INSERT(LPAD(HEX(UNIX_TIMESTAMP() * 1000 + FLOOR(MICROSECOND(NOW(6)) / 1000)), 12, '0'), 9, 0, '-'),
	'-7',
	LPAD(HEX(FLOOR(RAND() * 0x1000)), 3, '0'),
	'-',
	HEX(0x8000 | FLOOR(RAND() * 0x4000)),
	'-',
	LPAD(HEX(FLOOR(RAND() * 0x1000000000000)), 12, '0')
)) AS uuidv7;

You can either use this inline in your select statement, or convert it to a function.


UUIDv4 in MySQL

Although MySQL has a UUID() function, it returns a version 1 UUID, which is time-based and has mostly been replaced by the completely random version 4. I recently needed a v4 in a query, and adapted this from some different options I found online: You can either use this inline in your select statement, or convert […]


The Battle for Ducosi

Angel of Redemption, Dark Angels battle barge, 017M41.032.1130. From: Ikhnaton, fourth Company Grand Master, Master of the Fleet To: Azrael, Dark Angels Supreme Grand Master My lord, attached my report on our recent battle against the ancient enemy. We had been deploying our battle-brothers to the main planet of the Lothar system, when Rubicon squadron, send […]


Orc Blood Bowl team

With the re-release of this old classic last week, it’s time to show another of my Blood Bowl teams: Orcs. Like my human team these were painted according to the ‘How to paint’ leaflet that came with the third edition Blood Bowl set. This meant that they ended up as the Gouged Eye. As with […]


Librarian on bike

Just a quick one today: My recently completed bike-mounted librarian conversion. As always, Dark Angels. Conversion The bike is mostly the bike from the old bike-mounted chaplain kit. Which in turn was just a normal bike with a few metal bits added on: A fancier front guard, some items on the back and holstered boltgun. […]


Battlefleet Gothic: First ships

As I mentioned earlier, one of my goals for this year is to get a playable fleet ready for Battlefleet Gothic. Over the past month, I’ve done just that: Get started. Coming weekend, I’ll be playing a few games, and to that end I’ve been busy painting up a 1750 point Space Marine fleet. I […]


Mortis Pattern Dreadnought conversion

A while back I noticed my bit box contained two complete metal Dark Angel Dreadnoughts. The model with a lascannon and a missile launcher. I decided to combine them into a Mortis pattern dreadnought. This is an anti-air version of the dreadnought, which has two identical weapon arms and can gain the Skyfire special rule […]


Human Blood Bowl team

Another one of the old Specialist Games I’m a big fan of is Blood Bowl. I own three teams: My own primary teams is Dwarfs. But I also have the two teams that came with the third edition starter set (Humans and Orcs), which I use when I demonstrate the game to people. There is […]


Warhammer Quest — Core game pieces

As I said previously, one of my goals for this year is finishing the models for my 1995 Warhammer Quest set. By now, I’ve finished all the core game pieces, i.e., the models you need every game, so have some pictures! About Warhammer Quest For those that don’t know, Warhammer Quest is a co-op game […]


Combat patrol army, vehicle repairs

I realized I never posted a picture of my own army for the Combat Patrol tournament. I didn’t even take one, even though I displayed it for the best painted army vote. So here it is: For the close-combat scouts, I painted up an alternative sergeant to the one shown earlier, since a power sword is a […]