linkdotnet / Blog

A blog (engine) completely written in C# and Blazor. It aims to be a simple use and easy to extend platform. Blogposts are written in Markdown and are rendered to HTML. This gives all the flexibility needed to express yourself but also have an easy way of creating posts in the first place.
https://steven-giesel.com/
MIT License
287 stars 51 forks source link

Use OPEN_JSON for persisting tags #252

Closed linkdotnet closed 1 year ago

linkdotnet commented 1 year ago

This PR fixes #101

Open points:

Possible Migration for SqlServer:

ALTER TABLE [dbo].[BlogPosts]
ADD [Tags] [nvarchar](2048) NULL;
GO

UPDATE [dbo].[BlogPosts]
SET [Tags] = (
  SELECT '[' + STRING_AGG('"' + t.Content + '"', ',') + ']'
  FROM [dbo].[Tags] t
  WHERE t.BlogPostId = [dbo].[BlogPosts].[Id]
)

ALTER TABLE [dbo].[Tags]
DROP CONSTRAINT [FK_Tag_BlogPosts_BlogPostId]
GO

-- Drop the Tags table
DROP TABLE [dbo].[Tags]
GO