Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OPEN_JSON for persisting tags #252

Merged
merged 5 commits into from
Aug 1, 2023
Merged

Use OPEN_JSON for persisting tags #252

merged 5 commits into from
Aug 1, 2023

Conversation

linkdotnet
Copy link
Owner

@linkdotnet linkdotnet commented Aug 1, 2023

This PR fixes #101

Open points:

  • Does that work with MySQL?
  • Migration?

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

@linkdotnet linkdotnet merged commit a4a8fe4 into master Aug 1, 2023
1 check passed
@linkdotnet linkdotnet deleted the fix/#101 branch August 1, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating Tags in a blog post doesn't update
1 participant