<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://www.mortenbock.dk/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.mortenbock.dk/" rel="alternate" type="text/html" /><updated>2026-05-29T21:44:19+00:00</updated><id>https://www.mortenbock.dk/feed.xml</id><title type="html">Bock</title><subtitle>A collection of thoughts</subtitle><author><name>Morten Bock</name></author><entry><title type="html">Managing an evolving sql schema. A declarative approach.</title><link href="https://www.mortenbock.dk/sql-schema-management/" rel="alternate" type="text/html" title="Managing an evolving sql schema. A declarative approach." /><published>2026-05-29T00:00:00+00:00</published><updated>2026-05-29T00:00:00+00:00</updated><id>https://www.mortenbock.dk/sql-schema-management</id><content type="html" xml:base="https://www.mortenbock.dk/sql-schema-management/"><![CDATA[<p>For many years, I have been used to applications evolving therir sql schema via migrations. Different flavors like FluentMigrator or EF Core migrations, but essentially the same concept. A stream of instructions that modify a database.</p>

<p>It’s a fairly easy concept to understand, and it does have a nice design time feeling letting you feel in full control of what is actually going to happen to the schema when these changes are deployed.</p>

<p>It can have some challenges though, especially as a code base ages.</p>

<ul>
  <li>Long lists of migrations</li>
  <li>Artifacts describing tables that no longer exist</li>
  <li>Migrations being misused as “run something once” completely unrelated to sql schema</li>
  <li>Drift between the actual database, and the result of running migrations from scratch (someone made a direct change in SQL to fix a prod issue)</li>
</ul>

<p>I’m sure there are more, and yes, as always, these come down to not having the perfect process. But we’re all human (for now).</p>

<p>Still, it made me wonder if there was a different way to approach this. Then I saw a talk by <a href="https://github.com/erikej">Erik Ejlskov Jensen</a> introducing me to a different set of tools for MsSQL/SQL Server.</p>

<h2 id="enter-the-sql-project">Enter the Sql Project</h2>

<p>Using Microsofts own Sql Project, or the OSS <a href="https://github.com/rr-wfm/MSBuild.Sdk.SqlProj">MSBuild.Sdk.SqlProj</a> takes a different approach.</p>

<p>You define, in SQL, how you would like the database schema to look, and then you use the tooling when deploying to compare the desired state, to the current state of the target DB, and it will tell you what needs to change, and apply those changes.</p>

<p>A few reasons why I like this approach:</p>

<h3 id="more-coherent-file-structure">More coherent file structure</h3>

<p>For each table (and other objects), you will have a single <code class="language-plaintext highlighter-rouge">MyTable.sql</code> file, that contains the desired design for that table. This means it’s easy to see the full schema for it, and it’s easy to track historic changes to it via git.</p>

<p>I also prefer this over EF Code First migrations, where it is less obvoius how you need to design your model, to make the table exactly how you want it.</p>

<p>This is just native SQL.</p>

<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">-- MyTable.sql</span>
<span class="k">CREATE</span> <span class="k">TABLE</span> <span class="n">MyTable</span>
<span class="p">(</span>
    <span class="n">Foo</span> <span class="nb">CHAR</span> <span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span>
    <span class="n">Bar</span> <span class="nb">VARCHAR</span> <span class="p">(</span><span class="mi">50</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span>
<span class="p">);</span>
</code></pre></div></div>

<h3 id="drift-detection">Drift detection</h3>

<p>Using the tooling for SQL server in your deployment process, you can easily get warnings if the target database contains objects that your desired state does not. And if applying those changes would destroy data.</p>

<p>The tools can both generate a report of what changes are detected, and a SQL script to execute them that you can then review before applying.</p>

<h3 id="analyzers-for-good-practices">Analyzers for good practices</h3>

<p>Using the <a href="https://github.com/rr-wfm/MSBuild.Sdk.SqlProj">MSBuild.Sdk.SqlProj</a> style project, you can take advantage of a large set of analyzers that will let you know if you are making some typical mistakes that could hurt your database design.</p>

<p>It can also tell you if you are not following the naming schemes, and lots of nice reminders like that.</p>

<p>This is typically something that migrations do not give you, because they might only compile to SQL at runtime.</p>

<h2 id="should-you-use-it">Should you use it?</h2>

<p>If you are seeing some of the issues I mentioned with traditional migration processes, this might be worth a look.</p>

<p>I don’t know if MySQL and PostgreSQL have similar tooling options, but I imaging that companies like RedGate offer tools that acheive the same effect.</p>

<p>I found it much cleaner to just declare the desired state, and rely on good tools to apply them, over managing a changelog of diffs.</p>]]></content><author><name>Morten Bock</name></author><summary type="html"><![CDATA[A look into using a declarative approach to deploying sql schema changes.]]></summary></entry><entry><title type="html">20 years</title><link href="https://www.mortenbock.dk/it-has-been-20-years/" rel="alternate" type="text/html" title="20 years" /><published>2026-05-17T00:00:00+00:00</published><updated>2026-05-17T00:00:00+00:00</updated><id>https://www.mortenbock.dk/it-has-been-20-years</id><content type="html" xml:base="https://www.mortenbock.dk/it-has-been-20-years/"><![CDATA[<p>This month it’s been 20 years since I started my first real job in software. It’s also 20 years since I created my profile on LinkedIn. I think it’s fair to say that the field of software has changed a bit since then.</p>

<p>The first programming I ever did as a kid was learning Turbo Pascal with the kid next door, whose dad taught us. It was mainly getting the speaker to go beep, and printing funny words on the matrix printer.</p>

<p>Next I borrowed one of those C64 books with full code for a small game. After typing for hours, I was gutted that there were no graphics. That was the end of programming for a while.</p>

<p>Starting my 20’s I was actually aiming for a music career, but to get going I needed a website. So I started learning to make websites, and got a bit of education. I though I would be an entrepreneur, but turns out that is not what I actually enjoyed. It was the learning.</p>

<p>Tinkering with a problem, and figuring out how things work. That was the real joy.</p>

<p>So I got a web dev job. And it was a lot of this:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">$</span><span class="p">(</span><span class="dl">"</span><span class="s2">.that-button</span><span class="dl">"</span><span class="p">).</span><span class="nx">click</span><span class="p">()</span>
</code></pre></div></div>

<p>Building a bunch of websites I had no interest in, but it allowed me to learn stuff while building them. An that has basically been the same since. Building things for others, with the payoff that part of the job is picking something apart, and see what makes it tick.</p>

<p>That balance appears to be in danger, thanks to recent developments in the imitation machines. “Don’t spend time learning that, just make the machine learn it, and then ask how to do it”.</p>

<p>That is like watching someone else learning to play the guitar.</p>

<p>So I fear that if the current trend continues, there will be no joy left for me in my current profession. Which then begs the question: Where do we go from here?</p>

<p>I have no answer to that. It is still going to be around 20 more years before I can retire. So if I could spend 20 years getting to here in software, could I spend the next 20 doing something completely different? What would that even be?</p>

<p>Maybe the bubble will burst, and some sanity will return to the world. Or maybe we will never speak to an actual human again, because that is just too inefficient.</p>]]></content><author><name>Morten Bock</name></author><summary type="html"><![CDATA[I got my first software job 20 years ago. Reflections on the past and future.]]></summary></entry></feed>