using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace StubbedContextLib.Migrations { /// public partial class MyMigrations : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "DataSource", columns: table => new { IdSource = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), Model = table.Column(type: "TEXT", maxLength: 100, nullable: false), Precision = table.Column(type: "REAL", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DataSource", x => x.IdSource); }); migrationBuilder.CreateTable( name: "Athlete", columns: table => new { IdAthlete = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Username = table.Column(type: "TEXT", maxLength: 100, nullable: false), LastName = table.Column(type: "TEXT", maxLength: 100, nullable: false), FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), Email = table.Column(type: "TEXT", maxLength: 100, nullable: false), Sexe = table.Column(type: "TEXT", maxLength: 1, nullable: false), Length = table.Column(type: "REAL", nullable: false), Weight = table.Column(type: "REAL", nullable: false), Password = table.Column(type: "TEXT", nullable: false), DateOfBirth = table.Column(type: "TEXT", nullable: false), IsCoach = table.Column(type: "INTEGER", nullable: false), DataSourceId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Athlete", x => x.IdAthlete); table.ForeignKey( name: "FK_Athlete_DataSource_DataSourceId", column: x => x.DataSourceId, principalTable: "DataSource", principalColumn: "IdSource"); }); migrationBuilder.CreateTable( name: "Activity", columns: table => new { IdActivity = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), Date = table.Column(type: "TEXT", nullable: false), StartTime = table.Column(type: "TEXT", nullable: false), EndTime = table.Column(type: "TEXT", nullable: false), EffortFelt = table.Column(type: "INTEGER", nullable: false), Variability = table.Column(type: "REAL", nullable: false), Variance = table.Column(type: "REAL", nullable: false), StandardDeviation = table.Column(type: "REAL", nullable: false), Average = table.Column(type: "REAL", nullable: false), Maximum = table.Column(type: "INTEGER", nullable: false), Minimum = table.Column(type: "INTEGER", nullable: false), AverageTemperature = table.Column(type: "REAL", nullable: false), HasAutoPause = table.Column(type: "INTEGER", nullable: false), DataSourceId = table.Column(type: "INTEGER", nullable: false), AthleteId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Activity", x => x.IdActivity); table.ForeignKey( name: "FK_Activity_Athlete_AthleteId", column: x => x.AthleteId, principalTable: "Athlete", principalColumn: "IdAthlete"); table.ForeignKey( name: "FK_Activity_DataSource_DataSourceId", column: x => x.DataSourceId, principalTable: "DataSource", principalColumn: "IdSource"); }); migrationBuilder.CreateTable( name: "FriendshipEntity", columns: table => new { FollowingId = table.Column(type: "INTEGER", nullable: false), FollowerId = table.Column(type: "INTEGER", nullable: false), StartDate = table.Column(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( name: "Notification", columns: table => new { IdNotif = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Message = table.Column(type: "TEXT", maxLength: 100, nullable: false), Date = table.Column(type: "TEXT", nullable: false), Statut = table.Column(type: "INTEGER", nullable: false), Urgence = table.Column(type: "TEXT", maxLength: 100, nullable: false), SenderId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Notification", x => x.IdNotif); table.ForeignKey( name: "FK_Notification_Athlete_SenderId", column: x => x.SenderId, principalTable: "Athlete", principalColumn: "IdAthlete", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Statistic", columns: table => new { IdStatistic = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Weight = table.Column(type: "REAL", nullable: false), AverageHeartRate = table.Column(type: "REAL", nullable: false), MaximumHeartRate = table.Column(type: "REAL", nullable: false), AverageCaloriesBurned = table.Column(type: "REAL", nullable: false), Date = table.Column(type: "TEXT", nullable: false), AthleteId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Statistic", x => x.IdStatistic); table.ForeignKey( name: "FK_Statistic_Athlete_AthleteId", column: x => x.AthleteId, principalTable: "Athlete", principalColumn: "IdAthlete"); }); migrationBuilder.CreateTable( name: "Training", columns: table => new { IdTraining = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Date = table.Column(type: "TEXT", nullable: false), Description = table.Column(type: "TEXT", maxLength: 300, nullable: true), Latitude = table.Column(type: "REAL", nullable: false), Longitude = table.Column(type: "REAL", nullable: false), FeedBack = table.Column(type: "TEXT", maxLength: 300, nullable: true), CoachId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Training", x => x.IdTraining); table.ForeignKey( name: "FK_Training_Athlete_CoachId", column: x => x.CoachId, principalTable: "Athlete", principalColumn: "IdAthlete", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "HeartRate", columns: table => new { IdHeartRate = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Altitude = table.Column(type: "REAL", nullable: false), Time = table.Column(type: "TEXT", nullable: false), Temperature = table.Column(type: "REAL", nullable: false), Bpm = table.Column(type: "INTEGER", nullable: false), Longitude = table.Column(type: "REAL", nullable: false), Latitude = table.Column(type: "REAL", nullable: false), ActivityId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_HeartRate", x => x.IdHeartRate); table.ForeignKey( name: "FK_HeartRate_Activity_ActivityId", column: x => x.ActivityId, principalTable: "Activity", principalColumn: "IdActivity", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AthleteEntityNotificationEntity", columns: table => new { NotificationsReceivedIdNotif = table.Column(type: "INTEGER", nullable: false), ReceiversIdAthlete = table.Column(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(type: "INTEGER", nullable: false), TrainingsAthleteIdTraining = table.Column(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( table: "Athlete", columns: new[] { "IdAthlete", "DataSourceId", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "Sexe", "Username", "Weight" }, values: new object[,] { { 1, null, new DateOnly(1990, 1, 1), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f }, { 3, null, new DateOnly(1992, 1, 1), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", "M", "Martin", 68f }, { 4, null, new DateOnly(1993, 1, 1), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", "F", "Brown", 58f } }); migrationBuilder.InsertData( table: "DataSource", columns: new[] { "IdSource", "Model", "Precision", "Type" }, values: new object[,] { { 1, "Garmin", 0.5f, "Smartwatch" }, { 2, "Polar", 0.5f, "Smartwatch" }, { 3, "Suunto", 0.5f, "Smartwatch" }, { 4, "Fitbit", 0.5f, "Smartwatch" }, { 5, "Apple Watch", 0.5f, "Smartwatch" } }); migrationBuilder.InsertData( table: "Activity", columns: new[] { "IdActivity", "AthleteId", "Average", "AverageTemperature", "DataSourceId", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" }, values: new object[,] { { 1, 1, 0.5f, 20f, 1, new DateOnly(2023, 1, 10), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 0, 34), "Running", 0.5f, 0.5f }, { 3, 1, 0.5f, 20f, 1, new DateOnly(2023, 12, 10), 5, new TimeOnly(15, 2, 22), false, 0, 0, 0.5f, new TimeOnly(13, 30, 34), "Swimming", 0.5f, 0.5f }, { 5, 4, 0.5f, 20f, 4, new DateOnly(2024, 1, 12), 5, new TimeOnly(9, 0, 22), false, 0, 0, 0.5f, new TimeOnly(7, 45, 34), "Hiking", 0.5f, 0.5f }, { 6, 4, 0.5f, 20f, 4, new DateOnly(2024, 1, 27), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 30, 1), "Climbing", 0.5f, 0.5f }, { 7, 3, 0.5f, 20f, 5, new DateOnly(2024, 2, 22), 5, new TimeOnly(23, 50, 58), false, 0, 0, 0.5f, new TimeOnly(22, 0, 34), "Yoga", 0.5f, 0.5f } }); migrationBuilder.InsertData( table: "Athlete", columns: new[] { "IdAthlete", "DataSourceId", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "Sexe", "Username", "Weight" }, values: new object[,] { { 2, 1, new DateOnly(1995, 1, 1), "jane.smith@exemple.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", "F", "Smith", 60f }, { 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( table: "Notification", columns: new[] { "IdNotif", "Date", "Message", "SenderId", "Statut", "Urgence" }, values: new object[,] { { 1, new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified), "You have a new activity to check", 1, true, "A" }, { 3, new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified), "You have a new heart rate to check", 3, true, "2" }, { 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( table: "Statistic", columns: new[] { "IdStatistic", "AthleteId", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" }, values: new object[,] { { 1, 1, 500.0, 120.0, new DateOnly(2021, 12, 12), 180.0, 75f }, { 3, 1, 550.0, 125.0, new DateOnly(2022, 12, 30), 185.0, 68f }, { 4, 3, 650.0, 135.0, new DateOnly(2023, 2, 20), 195.0, 58f }, { 5, 4, 450.0, 110.0, new DateOnly(2024, 1, 10), 170.0, 90f } }); migrationBuilder.InsertData( table: "Training", columns: new[] { "IdTraining", "CoachId", "Date", "Description", "FeedBack", "Latitude", "Longitude" }, values: new object[,] { { 1, 1, new DateOnly(2024, 1, 19), "Running", "Good", 48.8566f, 2.3522f }, { 3, 4, new DateOnly(2024, 2, 21), null, "Good", 48.8566f, 2.3522f }, { 4, 3, new DateOnly(2024, 2, 22), "Running", "Good", 48.8566f, 2.3522f }, { 5, 1, new DateOnly(2024, 2, 23), "Cycling", null, 48.8566f, 2.3522f } }); migrationBuilder.InsertData( table: "Activity", columns: new[] { "IdActivity", "AthleteId", "Average", "AverageTemperature", "DataSourceId", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" }, values: new object[,] { { 2, 2, 0.5f, 20f, 2, new DateOnly(2023, 1, 25), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 4, 34), "Cycling", 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( table: "HeartRate", columns: new[] { "IdHeartRate", "ActivityId", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" }, values: new object[,] { { 1, 1, 0.0, 60, 66f, 35f, 20f, new TimeOnly(13, 0, 30) }, { 3, 1, 11.0, 71, 66f, 36f, 20f, new TimeOnly(13, 0, 32) } }); migrationBuilder.InsertData( table: "Notification", columns: new[] { "IdNotif", "Date", "Message", "SenderId", "Statut", "Urgence" }, values: new object[,] { { 2, new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified), "You have a new athlete to check", 2, false, "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( table: "Statistic", columns: new[] { "IdStatistic", "AthleteId", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" }, values: new object[] { 2, 2, 600.0, 130.0, new DateOnly(2021, 1, 11), 190.0, 60f }); migrationBuilder.InsertData( table: "Training", columns: new[] { "IdTraining", "CoachId", "Date", "Description", "FeedBack", "Latitude", "Longitude" }, values: new object[] { 2, 5, new DateOnly(2024, 2, 20), "Cycling", null, 48.8566f, 2.3522f }); migrationBuilder.InsertData( table: "HeartRate", columns: new[] { "IdHeartRate", "ActivityId", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" }, values: new object[,] { { 2, 2, 10.0, 65, 67f, 35f, 20.5f, new TimeOnly(13, 0, 31) }, { 4, 2, 12.0, 75, 67f, 36f, 20.5f, new TimeOnly(13, 0, 33) }, { 5, 4, 13.0, 80, 66f, 37f, 20f, new TimeOnly(13, 0, 34) } }); migrationBuilder.CreateIndex( name: "IX_Activity_AthleteId", table: "Activity", column: "AthleteId"); migrationBuilder.CreateIndex( name: "IX_Activity_DataSourceId", table: "Activity", column: "DataSourceId"); migrationBuilder.CreateIndex( name: "IX_Athlete_DataSourceId", table: "Athlete", 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( name: "IX_HeartRate_ActivityId", table: "HeartRate", column: "ActivityId"); migrationBuilder.CreateIndex( name: "IX_Notification_SenderId", table: "Notification", column: "SenderId"); migrationBuilder.CreateIndex( name: "IX_Statistic_AthleteId", table: "Statistic", column: "AthleteId"); migrationBuilder.CreateIndex( name: "IX_Training_CoachId", table: "Training", column: "CoachId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AthleteEntityNotificationEntity"); migrationBuilder.DropTable( name: "AthleteEntityTrainingEntity"); migrationBuilder.DropTable( name: "FriendshipEntity"); migrationBuilder.DropTable( name: "HeartRate"); migrationBuilder.DropTable( name: "Statistic"); migrationBuilder.DropTable( name: "Notification"); migrationBuilder.DropTable( name: "Training"); migrationBuilder.DropTable( name: "Activity"); migrationBuilder.DropTable( name: "Athlete"); migrationBuilder.DropTable( name: "DataSource"); } } }