-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abe14d3
commit c16565f
Showing
34 changed files
with
802 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Reflection; | ||
|
||
namespace MusicCatalogue.Data | ||
{ | ||
public static class MigrationUtilities | ||
{ | ||
/// <summary> | ||
/// Get the namespace for the migration SQL scripts | ||
/// </summary> | ||
/// <returns></returns> | ||
public static string GetSqlScriptNamespace() | ||
{ | ||
// The assumption is that there will be a SQL folder at the same level as this class | ||
// where the SQL script resources are held | ||
var dataAssemblyNamespace = MethodBase.GetCurrentMethod()?.DeclaringType?.Namespace ?? ""; | ||
var sqlScriptNamespace = $"{dataAssemblyNamespace}.Sql"; | ||
return sqlScriptNamespace; | ||
} | ||
|
||
/// <summary> | ||
/// Read and return the contents of an embedded resource containing a SQL migration script | ||
/// </summary> | ||
/// <param name="name"></param> | ||
/// <returns></returns> | ||
public static string ReadMigrationSqlScript(string name) | ||
{ | ||
string content = ""; | ||
|
||
// Get the resource name | ||
var sqlScriptNamespace = GetSqlScriptNamespace(); | ||
var sqlResourceName = $"{sqlScriptNamespace}.{name}"; | ||
|
||
// Get the name of the resource and a resource stream for reading it | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
var resourceStream = assembly.GetManifestResourceStream(sqlResourceName); | ||
|
||
// Open a stream reader to read the file content | ||
using (var reader = new StreamReader(resourceStream!)) | ||
{ | ||
// Read the file content | ||
content = reader.ReadToEnd(); | ||
} | ||
|
||
return content; | ||
} | ||
} | ||
} |
307 changes: 307 additions & 0 deletions
307
src/MusicCatalogue.Data/Migrations/20231115134404_GenresEntity.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.