using System; using Microsoft.EntityFrameworkCore.Migrations; namespace PersonSport.Migrations { public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Administratorer", columns: table => new { AdminId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Username = table.Column(type: "TEXT", maxLength: 40, nullable: false), Password = table.Column(type: "TEXT", maxLength: 80, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Administratorer", x => x.AdminId); }); migrationBuilder.CreateTable( name: "Personer", columns: table => new { PersonId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), PersonNamn = table.Column(type: "TEXT", maxLength: 50, nullable: false), Epost = table.Column(type: "TEXT", maxLength: 50, nullable: false), Alder = table.Column(type: "INTEGER", nullable: false), StartDatum = table.Column(type: "TEXT", nullable: false), Visningsbild = table.Column(type: "TEXT", maxLength: 80, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Personer", x => x.PersonId); }); migrationBuilder.CreateTable( name: "Sporter", columns: table => new { SportId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), SportNamn = table.Column(type: "TEXT", maxLength: 50, nullable: false), Bakgrundsbild = table.Column(type: "TEXT", maxLength: 60, nullable: false), Ingress = table.Column(type: "TEXT", maxLength: 200, nullable: false), DetaljText = table.Column(type: "TEXT", maxLength: 2000, nullable: true), Traningstider = table.Column(type: "TEXT", maxLength: 200, nullable: true) }, constraints: table => { table.PrimaryKey("PK_Sporter", x => x.SportId); }); migrationBuilder.CreateTable( name: "PersonSport", columns: table => new { PersonId = table.Column(type: "INTEGER", nullable: false), SportId = table.Column(type: "INTEGER", nullable: false), StartDatum = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PersonSport", x => new { x.PersonId, x.SportId }); table.ForeignKey( name: "FK_PersonSport_Personer_PersonId", column: x => x.PersonId, principalTable: "Personer", principalColumn: "PersonId", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_PersonSport_Sporter_SportId", column: x => x.SportId, principalTable: "Sporter", principalColumn: "SportId", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_PersonSport_SportId", table: "PersonSport", column: "SportId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Administratorer"); migrationBuilder.DropTable( name: "PersonSport"); migrationBuilder.DropTable( name: "Personer"); migrationBuilder.DropTable( name: "Sporter"); } } }