using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Web.Migrations { /// public partial class initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Addresss", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Street = table.Column(type: "nvarchar(max)", nullable: false), City = table.Column(type: "nvarchar(max)", nullable: false), State = table.Column(type: "nvarchar(max)", nullable: true), PostalCode = table.Column(type: "nvarchar(max)", nullable: false), Country = table.Column(type: "nvarchar(max)", nullable: false), CVR = table.Column(type: "nvarchar(max)", nullable: true), Email = table.Column(type: "nvarchar(max)", nullable: false), Mobile = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Addresss", x => x.Id); }); migrationBuilder.CreateTable( name: "Banners", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: false), LinkUrl = table.Column(type: "nvarchar(max)", nullable: false), ImageUrl = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Banners", x => x.Id); }); migrationBuilder.CreateTable( name: "Footers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(max)", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Owner = table.Column(type: "nvarchar(max)", nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: false), CreatedBy = table.Column(type: "nvarchar(max)", nullable: false), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: false), LastUpdated = table.Column(type: "datetime2", nullable: false), ImageUlr = table.Column(type: "nvarchar(max)", nullable: false), Sitecopyright = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Footers", x => x.Id); }); migrationBuilder.CreateTable( name: "Questionnaires", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(max)", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Questionnaires", x => x.Id); }); migrationBuilder.CreateTable( name: "SocialMedia", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Url = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SocialMedia", x => x.Id); }); migrationBuilder.CreateTable( name: "Subscriptions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: true), Email = table.Column(type: "nvarchar(max)", nullable: false), IsSubscribed = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Subscriptions", x => x.Id); }); migrationBuilder.CreateTable( name: "Pages", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Title = table.Column(type: "nvarchar(max)", nullable: false), Slug = table.Column(type: "nvarchar(max)", nullable: true), Content = table.Column(type: "nvarchar(max)", nullable: false), FooterId = table.Column(type: "int", nullable: false), BannerId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Pages", x => x.Id); table.ForeignKey( name: "FK_Pages_Banners_BannerId", column: x => x.BannerId, principalTable: "Banners", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Pages_Footers_FooterId", column: x => x.FooterId, principalTable: "Footers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Questions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Text = table.Column(type: "nvarchar(max)", nullable: true), Type = table.Column(type: "int", nullable: false), QuestionnaireId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Questions", x => x.Id); table.ForeignKey( name: "FK_Questions_Questionnaires_QuestionnaireId", column: x => x.QuestionnaireId, principalTable: "Questionnaires", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Responses", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), QuestionnaireId = table.Column(type: "int", nullable: false), UserName = table.Column(type: "nvarchar(max)", nullable: true), UserEmail = table.Column(type: "nvarchar(max)", nullable: true), SubmissionDate = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Responses", x => x.Id); table.ForeignKey( name: "FK_Responses_Questionnaires_QuestionnaireId", column: x => x.QuestionnaireId, principalTable: "Questionnaires", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "FooterSocialMedias", columns: table => new { FooterId = table.Column(type: "int", nullable: false), SocialId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_FooterSocialMedias", x => new { x.FooterId, x.SocialId }); table.ForeignKey( name: "FK_FooterSocialMedias_Footers_FooterId", column: x => x.FooterId, principalTable: "Footers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_FooterSocialMedias_SocialMedia_SocialId", column: x => x.SocialId, principalTable: "SocialMedia", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Answers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Text = table.Column(type: "nvarchar(max)", nullable: true), QuestionId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Answers", x => x.Id); table.ForeignKey( name: "FK_Answers_Questions_QuestionId", column: x => x.QuestionId, principalTable: "Questions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ResponseDetails", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ResponseId = table.Column(type: "int", nullable: false), QuestionId = table.Column(type: "int", nullable: false), QuestionType = table.Column(type: "int", nullable: false), TextResponse = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ResponseDetails", x => x.Id); table.ForeignKey( name: "FK_ResponseDetails_Questions_QuestionId", column: x => x.QuestionId, principalTable: "Questions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ResponseDetails_Responses_ResponseId", column: x => x.ResponseId, principalTable: "Responses", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ResponseAnswers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ResponseDetailId = table.Column(type: "int", nullable: false), AnswerId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ResponseAnswers", x => x.Id); table.ForeignKey( name: "FK_ResponseAnswers_ResponseDetails_ResponseDetailId", column: x => x.ResponseDetailId, principalTable: "ResponseDetails", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Answers_QuestionId", table: "Answers", column: "QuestionId"); migrationBuilder.CreateIndex( name: "IX_FooterSocialMedias_SocialId", table: "FooterSocialMedias", column: "SocialId"); migrationBuilder.CreateIndex( name: "IX_Pages_BannerId", table: "Pages", column: "BannerId"); migrationBuilder.CreateIndex( name: "IX_Pages_FooterId", table: "Pages", column: "FooterId"); migrationBuilder.CreateIndex( name: "IX_Questions_QuestionnaireId", table: "Questions", column: "QuestionnaireId"); migrationBuilder.CreateIndex( name: "IX_ResponseAnswers_ResponseDetailId", table: "ResponseAnswers", column: "ResponseDetailId"); migrationBuilder.CreateIndex( name: "IX_ResponseDetails_QuestionId", table: "ResponseDetails", column: "QuestionId"); migrationBuilder.CreateIndex( name: "IX_ResponseDetails_ResponseId", table: "ResponseDetails", column: "ResponseId"); migrationBuilder.CreateIndex( name: "IX_Responses_QuestionnaireId", table: "Responses", column: "QuestionnaireId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Addresss"); migrationBuilder.DropTable( name: "Answers"); migrationBuilder.DropTable( name: "FooterSocialMedias"); migrationBuilder.DropTable( name: "Pages"); migrationBuilder.DropTable( name: "ResponseAnswers"); migrationBuilder.DropTable( name: "Subscriptions"); migrationBuilder.DropTable( name: "SocialMedia"); migrationBuilder.DropTable( name: "Banners"); migrationBuilder.DropTable( name: "Footers"); migrationBuilder.DropTable( name: "ResponseDetails"); migrationBuilder.DropTable( name: "Questions"); migrationBuilder.DropTable( name: "Responses"); migrationBuilder.DropTable( name: "Questionnaires"); } } }