In this post I want to cover a couple of ways you can update a Database Project within the GitHub website. Because both ways can be useful.
I know most of the time files are updated using development tools on your own computer. However, it can be useful to know how you can update files within GitHub.
In fact, this post is one of the reasons why I made public a GitHub repository for a single Azure SQL Database deployment called GitHub-AzureSQLDatabase. So that you can clone it and use it with this post.
In addition, I updated my post about how to deploy to Azure SQL Database using GitHub Actions as well. So that it too has the link to this GitHub repository.
By the end of this post, you will know a couple of ways to update your Database Projects within GitHub. Along with advantages for doing both.
Note that this post is based on a SQL Server Database Project that uses state-based deployment. In reality, topics in this post also applies to other types of Database Projects that can be stored as code. As well as other deployment methods.
Before we start there is one other thing I would like to note. In these examples I show doing updates to the main branch to keep the demos simple. In the real world you should use a good branching strategy.
Introducing the web-based editor within GitHub
Let’s start with the web-based editor since it’s the newest method. Because I think it’s a really good way to update the repository.
It’s currently in beta preview and it is free for everyone to use in GitHub. I like to think of it as a taster for Codespaces.
How does it work? Well, one simple way to access it is to press the period button (.) whilst in a GitHub repository. Which is also known as a full stop to some. If you are quick, you will see the below sign whilst it is loading up.
Once loaded you will see the contents of your repository appear in a web-based version of Visual Studio Code.
In reality, this layout will be familiar to some of you. Because it’s a cloud-based version of Visual Studio Code. You can see this for yourself if you go into the menu on the left-hand side and select ‘About’.
Using this web-based editor allows you to work on a lightweight development area in the cloud. It can be very useful if you cannot setup a development environment locally to update your Database Project.
For those of you who have use GitHub Team or GitHub Enterprise Cloud this is similar to the initial look and feel of Codespaces. However, there are some significant differences. You can read the official GitHub documentation to see the differences between Codespaces and the web-based editor.
Viewing Database Project on Android
I can also confirm that it loads up if you use Chrome on an Android phone as well. If you use another OS on your phone, feel free to leave a comment if that also works.
Another key point is that you can use this for GitHub repositories which are used as a source for Azure Pipelines within Azure DevOps.
Update Database Projects in the web-based editor
Once opened up you can edit a file within the Database Project. For example, as you can see below, I’ve updated the schema for a table and the change to the Database Project has been recognized by source control.
From there, I can go into source control and commit my change. As you can see this will be committed directly to my branch in GitHub. This part updates my Database Project within GitHub.
Once I have committed the change it triggers a workflow to run in GitHub Actions. Which updates an Azure SQL Database.
Like I said earlier, this web-based editor is currently in beta and can change in the future. However, it does provide you a familiar way to work with your Database Projects within GitHub.
Editing within the GitHub website
You can still edit files directly in GitHub. By navigating within the code section and selecting the Edit icon. In the below example I have navigated to one of the files for a database table.
Updating a Database Project this way within GitHub can also trigger a workflow to run as well.
One area where this can be very useful is when you are editing workflows. Because it allows you to dynamically search the Marketplace on the right-hand side.
Final words about updating a Database Project within the GitHub website
I hope this post about a couple of ways you can update a Database Project within the GitHub website has been an interesting insight. Because both of the above methods have their advantages.
Bear in mind that the web-based editor is in beta and Codespaces is a better option if you have access to it.
Of course, if you have any comments or queries about this post feel free to reach out to me.