using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Somnia.GuestLog.Infrastructure.Migrations { /// public partial class AddTable_StayEntry : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "StayEntry", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DateIn = table.Column(type: "timestamp(0) with time zone", nullable: false), DateOut = table.Column(type: "timestamp(0) with time zone", nullable: false), RoomCount = table.Column(type: "integer", nullable: false), RoomNumber = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), PaymentMethod = table.Column(type: "character varying(5)", maxLength: 5, nullable: false), CreateTime = table.Column(type: "timestamp with time zone", nullable: false), UpdateTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StayEntry", x => x.Id); }); migrationBuilder.CreateTable( name: "GuestDocumentStayEntry", columns: table => new { StayEntryId = table.Column(type: "bigint", nullable: false), GuestDocumentsDocumentType = table.Column(type: "character varying(8)", nullable: false), GuestDocumentsDocumentNum = table.Column(type: "character varying(64)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_GuestDocumentStayEntry", x => new { x.StayEntryId, x.GuestDocumentsDocumentType, x.GuestDocumentsDocumentNum }); table.ForeignKey( name: "FK_GuestDocumentStayEntry_GuestDocument_GuestDocumentsDocument~", columns: x => new { x.GuestDocumentsDocumentType, x.GuestDocumentsDocumentNum }, principalTable: "GuestDocument", principalColumns: new[] { "DocumentType", "DocumentNum" }, onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_GuestDocumentStayEntry_StayEntry_StayEntryId", column: x => x.StayEntryId, principalTable: "StayEntry", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_GuestDocumentStayEntry_GuestDocumentsDocumentType_GuestDocu~", table: "GuestDocumentStayEntry", columns: new[] { "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "GuestDocumentStayEntry"); migrationBuilder.DropTable( name: "StayEntry"); } } }