using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace CMSMicroservice.Infrastructure.Persistence.Migrations { /// public partial class u08 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Categorys", schema: "CMS", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), ImagePath = table.Column(type: "nvarchar(max)", nullable: true), ParentId = table.Column(type: "bigint", nullable: true), IsActive = table.Column(type: "bit", nullable: false), SortOrder = table.Column(type: "int", nullable: false), Created = table.Column(type: "datetime2", nullable: false), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), LastModified = table.Column(type: "datetime2", nullable: true), LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Categorys", x => x.Id); table.ForeignKey( name: "FK_Categorys_Categorys_ParentId", column: x => x.ParentId, principalSchema: "CMS", principalTable: "Categorys", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Tags", schema: "CMS", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), SortOrder = table.Column(type: "int", nullable: false), Created = table.Column(type: "datetime2", nullable: false), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), LastModified = table.Column(type: "datetime2", nullable: true), LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tags", x => x.Id); }); migrationBuilder.CreateTable( name: "PruductCategorys", schema: "CMS", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProductId = table.Column(type: "bigint", nullable: false), CategoryId = table.Column(type: "bigint", nullable: false), Created = table.Column(type: "datetime2", nullable: false), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), LastModified = table.Column(type: "datetime2", nullable: true), LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PruductCategorys", x => x.Id); table.ForeignKey( name: "FK_PruductCategorys_Categorys_CategoryId", column: x => x.CategoryId, principalSchema: "CMS", principalTable: "Categorys", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PruductCategorys_Productss_ProductId", column: x => x.ProductId, principalSchema: "CMS", principalTable: "Productss", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "PruductTags", schema: "CMS", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProductId = table.Column(type: "bigint", nullable: false), TagId = table.Column(type: "bigint", nullable: false), Created = table.Column(type: "datetime2", nullable: false), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), LastModified = table.Column(type: "datetime2", nullable: true), LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PruductTags", x => x.Id); table.ForeignKey( name: "FK_PruductTags_Productss_ProductId", column: x => x.ProductId, principalSchema: "CMS", principalTable: "Productss", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PruductTags_Tags_TagId", column: x => x.TagId, principalSchema: "CMS", principalTable: "Tags", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Categorys_ParentId", schema: "CMS", table: "Categorys", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_PruductCategorys_CategoryId", schema: "CMS", table: "PruductCategorys", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_PruductCategorys_ProductId", schema: "CMS", table: "PruductCategorys", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_PruductTags_ProductId", schema: "CMS", table: "PruductTags", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_PruductTags_TagId", schema: "CMS", table: "PruductTags", column: "TagId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PruductCategorys", schema: "CMS"); migrationBuilder.DropTable( name: "PruductTags", schema: "CMS"); migrationBuilder.DropTable( name: "Categorys", schema: "CMS"); migrationBuilder.DropTable( name: "Tags", schema: "CMS"); } } }