ENEI2019-Public/api/Migrations/20190214165735_teams.cs

97 lines
3.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace api.Migrations
{
public partial class teams : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "TeamId",
table: "AspNetUsers",
nullable: true);
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Nome = table.Column<string>(nullable: true),
Event = table.Column<int>(nullable: false),
NumMemb = table.Column<int>(nullable: false),
VisitedNum = table.Column<int>(nullable: false),
Pontos = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EventQR",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Event = table.Column<int>(nullable: false),
TeamId = table.Column<int>(nullable: false),
EventLocId = table.Column<int>(nullable: false),
Pontos = table.Column<int>(nullable: false),
TimeGen = table.Column<DateTime>(nullable: false),
QRData = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EventQR", x => x.Id);
table.ForeignKey(
name: "FK_EventQR_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AspNetUsers_TeamId",
table: "AspNetUsers",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_EventQR_TeamId",
table: "EventQR",
column: "TeamId");
migrationBuilder.AddForeignKey(
name: "FK_AspNetUsers_Teams_TeamId",
table: "AspNetUsers",
column: "TeamId",
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AspNetUsers_Teams_TeamId",
table: "AspNetUsers");
migrationBuilder.DropTable(
name: "EventQR");
migrationBuilder.DropTable(
name: "Teams");
migrationBuilder.DropIndex(
name: "IX_AspNetUsers_TeamId",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "TeamId",
table: "AspNetUsers");
}
}
}