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
4 changes: 2 additions & 2 deletions src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public static IResourceBuilder<PostgresDatabaseResource> WithCreationScript(this
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(script);

builder.WithAnnotation(new CreationScriptAnnotation(script));
builder.WithAnnotation(new PostgresCreateDatabaseScriptAnnotation(script));

return builder;
}
Expand Down Expand Up @@ -493,7 +493,7 @@ private static string WritePgAdminServerJson(IEnumerable<PostgresServerResource>

private static async Task CreateDatabaseAsync(NpgsqlConnection npgsqlConnection, PostgresDatabaseResource npgsqlDatabase, IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
var scriptAnnotation = npgsqlDatabase.Annotations.OfType<CreationScriptAnnotation>().LastOrDefault();
var scriptAnnotation = npgsqlDatabase.Annotations.OfType<PostgresCreateDatabaseScriptAnnotation>().LastOrDefault();

try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.Postgres;

/// <summary>
/// Represents an annotation for defining a script to create a database in PostgreSQL.
/// </summary>
internal sealed class PostgresCreateDatabaseScriptAnnotation : IResourceAnnotation
{
/// <summary>
/// Initializes a new instance of the <see cref="PostgresCreateDatabaseScriptAnnotation"/> class.
/// </summary>
/// <param name="script">The script used to create the database.</param>
public PostgresCreateDatabaseScriptAnnotation(string script)
{
ArgumentNullException.ThrowIfNull(script);
Script = script;
}

/// <summary>
/// Gets the script used to create the database.
/// </summary>
public string Script { get; }
}
4 changes: 2 additions & 2 deletions src/Aspire.Hosting.SqlServer/SqlServerBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static IResourceBuilder<SqlServerDatabaseResource> WithCreationScript(thi
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(script);

builder.WithAnnotation(new CreationScriptAnnotation(script));
builder.WithAnnotation(new SqlServerCreateDatabaseScriptAnnotation(script));

return builder;
}
Expand All @@ -204,7 +204,7 @@ private static async Task CreateDatabaseAsync(SqlConnection sqlConnection, SqlSe
{
try
{
var scriptAnnotation = sqlDatabase.Annotations.OfType<CreationScriptAnnotation>().LastOrDefault();
var scriptAnnotation = sqlDatabase.Annotations.OfType<SqlServerCreateDatabaseScriptAnnotation>().LastOrDefault();

if (scriptAnnotation?.Script == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting;

/// <summary>
/// Represents an annotation for defining a script to create a database in SQL Server.
/// </summary>
internal sealed class SqlServerCreateDatabaseScriptAnnotation : IResourceAnnotation
{
/// <summary>
/// Initializes a new instance of the <see cref="SqlServerCreateDatabaseScriptAnnotation"/> class.
/// </summary>
/// <param name="script">The script used to create the database.</param>
public SqlServerCreateDatabaseScriptAnnotation(string script)
{
ArgumentNullException.ThrowIfNull(script);
Script = script;
}

/// <summary>
/// Gets the script used to create the database.
/// </summary>
public string Script { get; }
}
25 changes: 0 additions & 25 deletions src/Aspire.Hosting/ApplicationModel/CreationScriptAnnotation.cs

This file was deleted.

Loading