using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Posechaemost.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Groups", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Groups", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { UserId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FIO = table.Column(type: "text", nullable: false), GroupId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.UserId); table.ForeignKey( name: "FK_Users_Groups_GroupId", column: x => x.GroupId, principalTable: "Groups", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Presences", columns: table => new { PresenceId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Date = table.Column(type: "date", nullable: false), ClassNumber = table.Column(type: "integer", nullable: false), IsAttendence = table.Column(type: "boolean", nullable: false), UserId = table.Column(type: "integer", nullable: false), GroupId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Presences", x => x.PresenceId); table.ForeignKey( name: "FK_Presences_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "UserId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Presences_UserId", table: "Presences", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Users_GroupId", table: "Users", column: "GroupId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Presences"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Groups"); } } }