@ -85,8 +85,7 @@ namespace StubbedContextLib.Migrations
name : "FK_Activity_Athlete_AthleteId" ,
name : "FK_Activity_Athlete_AthleteId" ,
column : x = > x . AthleteId ,
column : x = > x . AthleteId ,
principalTable : "Athlete" ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
principalColumn : "IdAthlete" ) ;
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
table . ForeignKey (
name : "FK_Activity_DataSource_DataSourceId" ,
name : "FK_Activity_DataSource_DataSourceId" ,
column : x = > x . DataSourceId ,
column : x = > x . DataSourceId ,
@ -94,6 +93,31 @@ namespace StubbedContextLib.Migrations
principalColumn : "IdSource" ) ;
principalColumn : "IdSource" ) ;
} ) ;
} ) ;
migrationBuilder . CreateTable (
name : "FriendshipEntity" ,
columns : table = > new
{
FollowingId = table . Column < int > ( type : "INTEGER" , nullable : false ) ,
FollowerId = table . Column < int > ( type : "INTEGER" , nullable : false ) ,
StartDate = table . Column < DateTime > ( type : "TEXT" , nullable : false )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_FriendshipEntity" , x = > new { x . FollowingId , x . FollowerId } ) ;
table . ForeignKey (
name : "FK_FriendshipEntity_Athlete_FollowerId" ,
column : x = > x . FollowerId ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_FriendshipEntity_Athlete_FollowingId" ,
column : x = > x . FollowingId ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
onDelete : ReferentialAction . Cascade ) ;
} ) ;
migrationBuilder . CreateTable (
migrationBuilder . CreateTable (
name : "Notification" ,
name : "Notification" ,
columns : table = > new
columns : table = > new
@ -104,14 +128,14 @@ namespace StubbedContextLib.Migrations
Date = table . Column < DateTime > ( type : "TEXT" , nullable : false ) ,
Date = table . Column < DateTime > ( type : "TEXT" , nullable : false ) ,
Statut = table . Column < bool > ( type : "INTEGER" , nullable : false ) ,
Statut = table . Column < bool > ( type : "INTEGER" , nullable : false ) ,
Urgence = table . Column < string > ( type : "TEXT" , maxLength : 100 , nullable : false ) ,
Urgence = table . Column < string > ( type : "TEXT" , maxLength : 100 , nullable : false ) ,
Athlete Id = table . Column < int > ( type : "INTEGER" , nullable : false )
Sender Id = table . Column < int > ( type : "INTEGER" , nullable : false )
} ,
} ,
constraints : table = >
constraints : table = >
{
{
table . PrimaryKey ( "PK_Notification" , x = > x . IdNotif ) ;
table . PrimaryKey ( "PK_Notification" , x = > x . IdNotif ) ;
table . ForeignKey (
table . ForeignKey (
name : "FK_Notification_Athlete_ Athlete Id",
name : "FK_Notification_Athlete_ Sender Id",
column : x = > x . Athlete Id,
column : x = > x . Sender Id,
principalTable : "Athlete" ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
principalColumn : "IdAthlete" ,
onDelete : ReferentialAction . Cascade ) ;
onDelete : ReferentialAction . Cascade ) ;
@ -137,8 +161,7 @@ namespace StubbedContextLib.Migrations
name : "FK_Statistic_Athlete_AthleteId" ,
name : "FK_Statistic_Athlete_AthleteId" ,
column : x = > x . AthleteId ,
column : x = > x . AthleteId ,
principalTable : "Athlete" ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
principalColumn : "IdAthlete" ) ;
onDelete : ReferentialAction . Cascade ) ;
} ) ;
} ) ;
migrationBuilder . CreateTable (
migrationBuilder . CreateTable (
@ -152,14 +175,14 @@ namespace StubbedContextLib.Migrations
Latitude = table . Column < float > ( type : "REAL" , nullable : false ) ,
Latitude = table . Column < float > ( type : "REAL" , nullable : false ) ,
Longitude = table . Column < float > ( type : "REAL" , nullable : false ) ,
Longitude = table . Column < float > ( type : "REAL" , nullable : false ) ,
FeedBack = table . Column < string > ( type : "TEXT" , maxLength : 300 , nullable : true ) ,
FeedBack = table . Column < string > ( type : "TEXT" , maxLength : 300 , nullable : true ) ,
Athlete Id = table . Column < int > ( type : "INTEGER" , nullable : false )
Coach Id = table . Column < int > ( type : "INTEGER" , nullable : false )
} ,
} ,
constraints : table = >
constraints : table = >
{
{
table . PrimaryKey ( "PK_Training" , x = > x . IdTraining ) ;
table . PrimaryKey ( "PK_Training" , x = > x . IdTraining ) ;
table . ForeignKey (
table . ForeignKey (
name : "FK_Training_Athlete_ Athlete Id",
name : "FK_Training_Athlete_ Coach Id",
column : x = > x . Athlete Id,
column : x = > x . Coach Id,
principalTable : "Athlete" ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
principalColumn : "IdAthlete" ,
onDelete : ReferentialAction . Cascade ) ;
onDelete : ReferentialAction . Cascade ) ;
@ -190,6 +213,54 @@ namespace StubbedContextLib.Migrations
onDelete : ReferentialAction . Cascade ) ;
onDelete : ReferentialAction . Cascade ) ;
} ) ;
} ) ;
migrationBuilder . CreateTable (
name : "AthleteEntityNotificationEntity" ,
columns : table = > new
{
NotificationsReceivedIdNotif = table . Column < int > ( type : "INTEGER" , nullable : false ) ,
ReceiversIdAthlete = table . Column < int > ( type : "INTEGER" , nullable : false )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_AthleteEntityNotificationEntity" , x = > new { x . NotificationsReceivedIdNotif , x . ReceiversIdAthlete } ) ;
table . ForeignKey (
name : "FK_AthleteEntityNotificationEntity_Athlete_ReceiversIdAthlete" ,
column : x = > x . ReceiversIdAthlete ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_AthleteEntityNotificationEntity_Notification_NotificationsReceivedIdNotif" ,
column : x = > x . NotificationsReceivedIdNotif ,
principalTable : "Notification" ,
principalColumn : "IdNotif" ,
onDelete : ReferentialAction . Cascade ) ;
} ) ;
migrationBuilder . CreateTable (
name : "AthleteEntityTrainingEntity" ,
columns : table = > new
{
AthletesIdAthlete = table . Column < int > ( type : "INTEGER" , nullable : false ) ,
TrainingsAthleteIdTraining = table . Column < int > ( type : "INTEGER" , nullable : false )
} ,
constraints : table = >
{
table . PrimaryKey ( "PK_AthleteEntityTrainingEntity" , x = > new { x . AthletesIdAthlete , x . TrainingsAthleteIdTraining } ) ;
table . ForeignKey (
name : "FK_AthleteEntityTrainingEntity_Athlete_AthletesIdAthlete" ,
column : x = > x . AthletesIdAthlete ,
principalTable : "Athlete" ,
principalColumn : "IdAthlete" ,
onDelete : ReferentialAction . Cascade ) ;
table . ForeignKey (
name : "FK_AthleteEntityTrainingEntity_Training_TrainingsAthleteIdTraining" ,
column : x = > x . TrainingsAthleteIdTraining ,
principalTable : "Training" ,
principalColumn : "IdTraining" ,
onDelete : ReferentialAction . Cascade ) ;
} ) ;
migrationBuilder . InsertData (
migrationBuilder . InsertData (
table : "Athlete" ,
table : "Athlete" ,
columns : new [ ] { "IdAthlete" , "DataSourceId" , "DateOfBirth" , "Email" , "FirstName" , "IsCoach" , "LastName" , "Length" , "Password" , "Sexe" , "Username" , "Weight" } ,
columns : new [ ] { "IdAthlete" , "DataSourceId" , "DateOfBirth" , "Email" , "FirstName" , "IsCoach" , "LastName" , "Length" , "Password" , "Sexe" , "Username" , "Weight" } ,
@ -233,14 +304,23 @@ namespace StubbedContextLib.Migrations
{ 5 , 3 , new DateOnly ( 1991 , 1 , 1 ) , "bruce.lee@example.com" , "Bruce" , false , "Lee" , 2.0 , "hello321" , "M" , "Lee" , 90f }
{ 5 , 3 , new DateOnly ( 1991 , 1 , 1 ) , "bruce.lee@example.com" , "Bruce" , false , "Lee" , 2.0 , "hello321" , "M" , "Lee" , 90f }
} ) ;
} ) ;
migrationBuilder . InsertData (
table : "FriendshipEntity" ,
columns : new [ ] { "FollowerId" , "FollowingId" , "StartDate" } ,
values : new object [ , ]
{
{ 1 , 3 , new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) } ,
{ 1 , 4 , new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) }
} ) ;
migrationBuilder . InsertData (
migrationBuilder . InsertData (
table : "Notification" ,
table : "Notification" ,
columns : new [ ] { "IdNotif" , "AthleteId" , "Date" , "Message" , "Statut" , "Urgence" } ,
columns : new [ ] { "IdNotif" , " Date", "Message ", "SenderId ", "Statut" , "Urgence" } ,
values : new object [ , ]
values : new object [ , ]
{
{
{ 1 , 1 , new DateTime ( 2023 , 12 , 25 , 13 , 0 , 40 , 0 , DateTimeKind . Unspecified ) , "You have a new activity to check" , true , "A" } ,
{ 1 , new DateTime ( 2023 , 12 , 25 , 13 , 0 , 40 , 0 , DateTimeKind . Unspecified ) , "You have a new activity to check" , 1 , true , "A" } ,
{ 3 , 3 , new DateTime ( 2023 , 12 , 26 , 16 , 10 , 4 , 0 , DateTimeKind . Unspecified ) , "You have a new heart rate to check" , true , "2" } ,
{ 3 , new DateTime ( 2023 , 12 , 26 , 16 , 10 , 4 , 0 , DateTimeKind . Unspecified ) , "You have a new heart rate to check" , 3 , true , "2" } ,
{ 4 , 4 , new DateTime ( 2024 , 1 , 12 , 9 , 30 , 50 , 0 , DateTimeKind . Unspecified ) , "You have a new data source to check" , false , "1" }
{ 4 , new DateTime ( 2024 , 1 , 12 , 9 , 30 , 50 , 0 , DateTimeKind . Unspecified ) , "You have a new data source to check" , 4 , false , "1" }
} ) ;
} ) ;
migrationBuilder . InsertData (
migrationBuilder . InsertData (
@ -256,7 +336,7 @@ namespace StubbedContextLib.Migrations
migrationBuilder . InsertData (
migrationBuilder . InsertData (
table : "Training" ,
table : "Training" ,
columns : new [ ] { "IdTraining" , " Athlete Id", "Date" , "Description" , "FeedBack" , "Latitude" , "Longitude" } ,
columns : new [ ] { "IdTraining" , " Coach Id", "Date" , "Description" , "FeedBack" , "Latitude" , "Longitude" } ,
values : new object [ , ]
values : new object [ , ]
{
{
{ 1 , 1 , new DateOnly ( 2024 , 1 , 19 ) , "Running" , "Good" , 48.8566f , 2.3522f } ,
{ 1 , 1 , new DateOnly ( 2024 , 1 , 19 ) , "Running" , "Good" , 48.8566f , 2.3522f } ,
@ -274,6 +354,17 @@ namespace StubbedContextLib.Migrations
{ 4 , 5 , 0.5f , 20f , 3 , new DateOnly ( 2024 , 1 , 2 ) , 5 , new TimeOnly ( 16 , 1 , 55 ) , false , 0 , 0 , 0.5f , new TimeOnly ( 15 , 0 , 0 ) , "Walking" , 0.5f , 0.5f }
{ 4 , 5 , 0.5f , 20f , 3 , new DateOnly ( 2024 , 1 , 2 ) , 5 , new TimeOnly ( 16 , 1 , 55 ) , false , 0 , 0 , 0.5f , new TimeOnly ( 15 , 0 , 0 ) , "Walking" , 0.5f , 0.5f }
} ) ;
} ) ;
migrationBuilder . InsertData (
table : "FriendshipEntity" ,
columns : new [ ] { "FollowerId" , "FollowingId" , "StartDate" } ,
values : new object [ , ]
{
{ 2 , 1 , new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) } ,
{ 1 , 2 , new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) } ,
{ 2 , 3 , new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) } ,
{ 1 , 5 , new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Unspecified ) }
} ) ;
migrationBuilder . InsertData (
migrationBuilder . InsertData (
table : "HeartRate" ,
table : "HeartRate" ,
columns : new [ ] { "IdHeartRate" , "ActivityId" , "Altitude" , "Bpm" , "Latitude" , "Longitude" , "Temperature" , "Time" } ,
columns : new [ ] { "IdHeartRate" , "ActivityId" , "Altitude" , "Bpm" , "Latitude" , "Longitude" , "Temperature" , "Time" } ,
@ -285,11 +376,11 @@ namespace StubbedContextLib.Migrations
migrationBuilder . InsertData (
migrationBuilder . InsertData (
table : "Notification" ,
table : "Notification" ,
columns : new [ ] { "IdNotif" , " AthleteId", " Date", "Message ", "Statut" , "Urgence" } ,
columns : new [ ] { "IdNotif" , " Date", "Message ", "SenderId ", "Statut" , "Urgence" } ,
values : new object [ , ]
values : new object [ , ]
{
{
{ 2 , 2 , new DateTime ( 2023 , 12 , 26 , 13 , 10 , 40 , 0 , DateTimeKind . Unspecified ) , "You have a new athlete to check" , false , "3" } ,
{ 2 , new DateTime ( 2023 , 12 , 26 , 13 , 10 , 40 , 0 , DateTimeKind . Unspecified ) , "You have a new athlete to check" , 2 , false , "3" } ,
{ 5 , 5 , new DateTime ( 2024 , 2 , 22 , 12 , 10 , 0 , 0 , DateTimeKind . Unspecified ) , "You have a new notification to check" , true , "3" }
{ 5 , new DateTime ( 2024 , 2 , 22 , 12 , 10 , 0 , 0 , DateTimeKind . Unspecified ) , "You have a new notification to check" , 5 , true , "3" }
} ) ;
} ) ;
migrationBuilder . InsertData (
migrationBuilder . InsertData (
@ -299,7 +390,7 @@ namespace StubbedContextLib.Migrations
migrationBuilder . InsertData (
migrationBuilder . InsertData (
table : "Training" ,
table : "Training" ,
columns : new [ ] { "IdTraining" , " Athlete Id", "Date" , "Description" , "FeedBack" , "Latitude" , "Longitude" } ,
columns : new [ ] { "IdTraining" , " Coach Id", "Date" , "Description" , "FeedBack" , "Latitude" , "Longitude" } ,
values : new object [ ] { 2 , 5 , new DateOnly ( 2024 , 2 , 20 ) , "Cycling" , null , 48.8566f , 2.3522f } ) ;
values : new object [ ] { 2 , 5 , new DateOnly ( 2024 , 2 , 20 ) , "Cycling" , null , 48.8566f , 2.3522f } ) ;
migrationBuilder . InsertData (
migrationBuilder . InsertData (
@ -327,15 +418,30 @@ namespace StubbedContextLib.Migrations
table : "Athlete" ,
table : "Athlete" ,
column : "DataSourceId" ) ;
column : "DataSourceId" ) ;
migrationBuilder . CreateIndex (
name : "IX_AthleteEntityNotificationEntity_ReceiversIdAthlete" ,
table : "AthleteEntityNotificationEntity" ,
column : "ReceiversIdAthlete" ) ;
migrationBuilder . CreateIndex (
name : "IX_AthleteEntityTrainingEntity_TrainingsAthleteIdTraining" ,
table : "AthleteEntityTrainingEntity" ,
column : "TrainingsAthleteIdTraining" ) ;
migrationBuilder . CreateIndex (
name : "IX_FriendshipEntity_FollowerId" ,
table : "FriendshipEntity" ,
column : "FollowerId" ) ;
migrationBuilder . CreateIndex (
migrationBuilder . CreateIndex (
name : "IX_HeartRate_ActivityId" ,
name : "IX_HeartRate_ActivityId" ,
table : "HeartRate" ,
table : "HeartRate" ,
column : "ActivityId" ) ;
column : "ActivityId" ) ;
migrationBuilder . CreateIndex (
migrationBuilder . CreateIndex (
name : "IX_Notification_AthleteId" ,
name : "IX_Notification_ Sender Id",
table : "Notification" ,
table : "Notification" ,
column : "AthleteId" ) ;
column : " Sender Id") ;
migrationBuilder . CreateIndex (
migrationBuilder . CreateIndex (
name : "IX_Statistic_AthleteId" ,
name : "IX_Statistic_AthleteId" ,
@ -343,23 +449,32 @@ namespace StubbedContextLib.Migrations
column : "AthleteId" ) ;
column : "AthleteId" ) ;
migrationBuilder . CreateIndex (
migrationBuilder . CreateIndex (
name : "IX_Training_ Athlete Id",
name : "IX_Training_ Coach Id",
table : "Training" ,
table : "Training" ,
column : " Athlete Id") ;
column : " Coach Id") ;
}
}
/// <inheritdoc />
/// <inheritdoc />
protected override void Down ( MigrationBuilder migrationBuilder )
protected override void Down ( MigrationBuilder migrationBuilder )
{
{
migrationBuilder . DropTable (
migrationBuilder . DropTable (
name : " HeartRate ") ;
name : " AthleteEntityNotificationEntity ") ;
migrationBuilder . DropTable (
migrationBuilder . DropTable (
name : "Notification" ) ;
name : "AthleteEntityTrainingEntity" ) ;
migrationBuilder . DropTable (
name : "FriendshipEntity" ) ;
migrationBuilder . DropTable (
name : "HeartRate" ) ;
migrationBuilder . DropTable (
migrationBuilder . DropTable (
name : "Statistic" ) ;
name : "Statistic" ) ;
migrationBuilder . DropTable (
name : "Notification" ) ;
migrationBuilder . DropTable (
migrationBuilder . DropTable (
name : "Training" ) ;
name : "Training" ) ;