using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Demo.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 { Guid = table.Column(type: "uuid", nullable: false), FIO = table.Column(type: "text", nullable: false), GroupID = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Guid); table.ForeignKey( name: "FK_Users_Groups_GroupID", column: x => x.GroupID, principalTable: "Groups", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PresenceDaos", columns: table => new { UserGuid = table.Column(type: "uuid", nullable: false), Date = table.Column(type: "date", nullable: false), LessonNumber = table.Column(type: "integer", nullable: false), IsAttedance = table.Column(type: "boolean", nullable: false), userDAOGuid = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PresenceDaos", x => new { x.UserGuid, x.Date, x.LessonNumber }); table.ForeignKey( name: "FK_PresenceDaos_Users_userDAOGuid", column: x => x.userDAOGuid, principalTable: "Users", principalColumn: "Guid", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_PresenceDaos_userDAOGuid", table: "PresenceDaos", column: "userDAOGuid"); migrationBuilder.CreateIndex( name: "IX_Users_GroupID", table: "Users", column: "GroupID"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PresenceDaos"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Groups"); } } }