120 lines
4.6 KiB
C#
120 lines
4.6 KiB
C#
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace ThAmCo.Events.Data.Migrations
|
|
{
|
|
public partial class AddStaffing : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "VenueReference",
|
|
schema: "thamco.events",
|
|
table: "Events",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Staff",
|
|
schema: "thamco.events",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
|
|
Surname = table.Column<string>(nullable: false),
|
|
FirstName = table.Column<string>(nullable: false),
|
|
Email = table.Column<string>(nullable: false),
|
|
FirstAid = table.Column<bool>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Staff", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Staffing",
|
|
schema: "thamco.events",
|
|
columns: table => new
|
|
{
|
|
StaffId = table.Column<int>(nullable: false),
|
|
EventId = table.Column<int>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Staffing", x => new { x.StaffId, x.EventId });
|
|
table.ForeignKey(
|
|
name: "FK_Staffing_Events_EventId",
|
|
column: x => x.EventId,
|
|
principalSchema: "thamco.events",
|
|
principalTable: "Events",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Staffing_Staff_StaffId",
|
|
column: x => x.StaffId,
|
|
principalSchema: "thamco.events",
|
|
principalTable: "Staff",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "thamco.events",
|
|
table: "Staff",
|
|
columns: new[] { "Id", "Email", "FirstAid", "FirstName", "Surname" },
|
|
values: new object[] { 1, "a@a.a", false, "Alan", "Partridge" });
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "thamco.events",
|
|
table: "Staff",
|
|
columns: new[] { "Id", "Email", "FirstAid", "FirstName", "Surname" },
|
|
values: new object[] { 2, "rege@hotmail.com", true, "Roger", "Stephenson" });
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "thamco.events",
|
|
table: "Staff",
|
|
columns: new[] { "Id", "Email", "FirstAid", "FirstName", "Surname" },
|
|
values: new object[] { 3, "alans@jims.net", false, "Alans", "Smith" });
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "thamco.events",
|
|
table: "Staffing",
|
|
columns: new[] { "StaffId", "EventId" },
|
|
values: new object[] { 1, 2 });
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "thamco.events",
|
|
table: "Staffing",
|
|
columns: new[] { "StaffId", "EventId" },
|
|
values: new object[] { 2, 1 });
|
|
|
|
migrationBuilder.InsertData(
|
|
schema: "thamco.events",
|
|
table: "Staffing",
|
|
columns: new[] { "StaffId", "EventId" },
|
|
values: new object[] { 3, 1 });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Staffing_EventId",
|
|
schema: "thamco.events",
|
|
table: "Staffing",
|
|
column: "EventId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Staffing",
|
|
schema: "thamco.events");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Staff",
|
|
schema: "thamco.events");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "VenueReference",
|
|
schema: "thamco.events",
|
|
table: "Events");
|
|
}
|
|
}
|
|
}
|