Updated Readme and script to add migrations

This commit is contained in:
kdeng00
2024-06-18 13:14:57 -04:00
parent cd5ee7d093
commit c6257da717
2 changed files with 20 additions and 16 deletions
+6 -3
View File
@@ -117,7 +117,7 @@ Prior to starting the API, the Migrations must be applied. There are 6 tables wi
* Song * Song
* Album * Album
* Artist * Artist
* Year * CoverArt
* Genre * Genre
There is a script for Linux systems to apply these migrations, it can be found in the [Scripts/Migrations/Linux](https://github.com/kdeng00/Icarus/blob/master/Scripts/Migrations/Linux/AddUpdate.sh) directory. Just merely execute: There is a script for Linux systems to apply these migrations, it can be found in the [Scripts/Migrations/Linux](https://github.com/kdeng00/Icarus/blob/master/Scripts/Migrations/Linux/AddUpdate.sh) directory. Just merely execute:
@@ -126,12 +126,15 @@ scripts/Migrations/Linux/AddUpdate.sh
``` ```
Or you can manually add the migrations like so for each migration: Or you can manually add the migrations like so for each migration:
```shell ```shell
dotnet ef migrations Add [Migration] --context [Migration]Context dotnet-ef migrations Add InitialCreate --context UserContext
``` ```
Then update the migrations to the database like so<sup>*</sup>: Then update the migrations to the database like so<sup>*</sup>:
```shell ```shell
dotnet ef database update --context [Migration]Context dotnet-ef database update --context UserContext
``` ```
All of the contexts can be found in Database/Contexts folder.
From this point the database has been successfully configured. Metadata and song filesystem locations can be saved. From this point the database has been successfully configured. Metadata and song filesystem locations can be saved.
<sup>*</sup> Will only need to execute this for UserContext and SongContext because the Song table has relational constraints with Album, Artist, Year, and Genre. <sup>*</sup> Will only need to execute this for UserContext and SongContext because the Song table has relational constraints with Album, Artist, Year, and Genre.
+14 -13
View File
@@ -1,26 +1,27 @@
echo "Adding migrations..." echo "Adding migrations..."
echo "Adding User migration" echo "Adding User migration"
dotnet ef migrations add User --context UserContext dotnet-ef migrations add User --context UserContext
echo "Adding Song migration"
dotnet ef migrations add Song --context SongContext
echo "Adding Album migration" echo "Adding Album migration"
dotnet ef migrations add Album --context AlbumContext dotnet-ef migrations add Album --context AlbumContext
echo "Adding Artist migration" echo "Adding Artist migration"
dotnet ef migrations add Artist --context ArtistContext dotnet-ef migrations add Artist --context ArtistContext
echo "Adding Genre migration" echo "Adding Genre migration"
dotnet ef migrations add Genre --context GenreContext dotnet-ef migrations add Genre --context GenreContext
echo "Adding Year migration"
dotnet ef migrations add Year --context YearContext
echo "Adding Cover art migration" echo "Adding Cover art migration"
dotnet ef migrations add CoverArt --context CoverArtContext dotnet-ef migrations add CoverArt --context CoverArtContext
echo "Adding Song migration"
dotnet-ef migrations add Song --context SongContext
echo "Updating migrations.." echo "Updating migrations.."
echo "Updating User migration" echo "Updating User migration"
dotnet ef database update --context UserContext dotnet-ef database update --context UserContext
echo "Updating Song migration"
echo "Updating Album migration" echo "Updating Album migration"
dotnet-ef database update --context AlbumContext
echo "Updating Artist migration" echo "Updating Artist migration"
dotnet-ef database update --context ArtistContext
echo "Updating Genre migration" echo "Updating Genre migration"
echo "Updating Year migration" dotnet-ef database update --context GenreContext
echo "Updating Cover art migration" echo "Updating Cover art migration"
dotnet ef database update --context SongContext dotnet-ef database update --context CoverArtContext
echo "Updating Song migration"
dotnet-ef database update --context SongContext