Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace LinkDotNet.Blog.Infrastructure.Migrations;
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace for this migration file is inconsistent with other migration files in the same directory. All other migrations in the codebase use LinkDotNet.Blog.Web.Migrations as their namespace (see 20250830110439_AddAuthorNameInBlogPost.cs, 20260109211327_AddBlogPostTemplate.cs, and 20260125204524_AddExternalIdToBlogPost.cs), but this file uses LinkDotNet.Blog.Infrastructure.Migrations. This inconsistency could lead to confusion and potential issues with migration discovery. Please change the namespace to match the established convention.

Copilot uses AI. Check for mistakes.

/// <inheritdoc />
public partial class AddUniqueIndexOnExternalId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);

migrationBuilder.CreateIndex(
name: "IX_BlogPosts_ExternalId",
table: "BlogPosts",
column: "ExternalId",
unique: true,
filter: "ExternalId IS NOT NULL");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
ArgumentNullException.ThrowIfNull(migrationBuilder);

migrationBuilder.DropIndex(
name: "IX_BlogPosts_ExternalId",
table: "BlogPosts");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasKey("Id");

b.HasIndex("ExternalId")
.IsUnique()
.HasDatabaseName("IX_BlogPosts_ExternalId")
.HasFilter("ExternalId IS NOT NULL");

b.HasIndex("IsPublished", "UpdatedDate")
.IsDescending(false, true)
.HasDatabaseName("IX_BlogPosts_IsPublished_UpdatedDate");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public void Configure(EntityTypeBuilder<BlogPost> builder)
builder.Property(x => x.AuthorName).HasMaxLength(256).IsRequired(false);
builder.Property(x => x.ExternalId).HasMaxLength(256).IsRequired(false);

builder.HasIndex(x => x.ExternalId)
.HasDatabaseName("IX_BlogPosts_ExternalId")
.IsUnique()
.HasFilter("ExternalId IS NOT NULL");

builder.HasIndex(x => new { x.IsPublished, x.UpdatedDate })
.HasDatabaseName("IX_BlogPosts_IsPublished_UpdatedDate")
.IsDescending(false, true);
Expand Down
Loading
Loading