Skip to content

Commit

Permalink
Fix Alerts migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Mar 25, 2020
1 parent a7e8673 commit e6f32c3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 42 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
DeviceID = table.Column<string>(nullable: true),
Message = table.Column<string>(nullable: true),
OrganizationID = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true),
UserIDId = table.Column<string>(nullable: true)
UserID = table.Column<string>(nullable: true)
},
constraints: table =>
{
Expand All @@ -34,14 +33,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Alerts_RemotelyUsers_UserIDId",
column: x => x.UserIDId,
principalTable: "RemotelyUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Alerts_RemotelyUsers_UserId",
column: x => x.UserId,
name: "FK_Alerts_RemotelyUsers_UserID",
column: x => x.UserID,
principalTable: "RemotelyUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
Expand All @@ -58,14 +51,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
column: "OrganizationID");

migrationBuilder.CreateIndex(
name: "IX_Alerts_UserIDId",
table: "Alerts",
column: "UserIDId");

migrationBuilder.CreateIndex(
name: "IX_Alerts_UserId",
name: "IX_Alerts_UserID",
table: "Alerts",
column: "UserId");
column: "UserID");
}

protected override void Down(MigrationBuilder migrationBuilder)
Expand Down
15 changes: 3 additions & 12 deletions Server/Migrations/ApplicationDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("OrganizationID")
.HasColumnType("TEXT");

b.Property<string>("UserIDId")
.HasColumnType("TEXT");

b.Property<string>("UserId")
b.Property<string>("UserID")
.HasColumnType("TEXT");

b.HasKey("ID");
Expand All @@ -248,9 +245,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("OrganizationID");

b.HasIndex("UserIDId");

b.HasIndex("UserId");
b.HasIndex("UserID");

b.ToTable("Alerts");
});
Expand Down Expand Up @@ -631,13 +626,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.WithMany("Alerts")
.HasForeignKey("OrganizationID");

b.HasOne("Remotely.Shared.Models.RemotelyUser", "UserID")
.WithMany()
.HasForeignKey("UserIDId");

b.HasOne("Remotely.Shared.Models.RemotelyUser", "User")
.WithMany("Alerts")
.HasForeignKey("UserId");
.HasForeignKey("UserID");
});

modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b =>
Expand Down
14 changes: 14 additions & 0 deletions Tests/DataServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,19 @@ public async Task UpdateServerAdmins()
Assert.AreEqual(1, currentAdmins.Count);
Assert.AreEqual(TestData.Admin2.UserName, currentAdmins[0]);
}

[TestMethod]
[DoNotParallelize]
public async Task AddAlert()
{
var alert = new Alert()
{
DeviceID = TestData.Device1.ID,
OrganizationID = TestData.OrganizationID,
Message = "Test Message",
UserID = TestData.Admin1.Id
};
await DataService.AddAlert(alert);
}
}
}

0 comments on commit e6f32c3

Please sign in to comment.