|
| 1 | +using System; |
| 2 | +using Microsoft.EntityFrameworkCore.Migrations; |
| 3 | + |
| 4 | +#nullable disable |
| 5 | + |
| 6 | +namespace FSH.Starter.WebApi.Migrations.MSSQL.Catalog |
| 7 | +{ |
| 8 | + /// <inheritdoc /> |
| 9 | + public partial class AddCatalogSchema : Migration |
| 10 | + { |
| 11 | + /// <inheritdoc /> |
| 12 | + protected override void Up(MigrationBuilder migrationBuilder) |
| 13 | + { |
| 14 | + migrationBuilder.EnsureSchema( |
| 15 | + name: "catalog"); |
| 16 | + |
| 17 | + migrationBuilder.CreateTable( |
| 18 | + name: "Brands", |
| 19 | + schema: "catalog", |
| 20 | + columns: table => new |
| 21 | + { |
| 22 | + Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| 23 | + Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false), |
| 24 | + Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
| 25 | + TenantId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
| 26 | + Created = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), |
| 27 | + CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| 28 | + LastModified = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), |
| 29 | + LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| 30 | + Deleted = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true), |
| 31 | + DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true) |
| 32 | + }, |
| 33 | + constraints: table => |
| 34 | + { |
| 35 | + table.PrimaryKey("PK_Brands", x => x.Id); |
| 36 | + }); |
| 37 | + |
| 38 | + migrationBuilder.CreateTable( |
| 39 | + name: "Products", |
| 40 | + schema: "catalog", |
| 41 | + columns: table => new |
| 42 | + { |
| 43 | + Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| 44 | + Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false), |
| 45 | + Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
| 46 | + Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false), |
| 47 | + BrandId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| 48 | + TenantId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
| 49 | + Created = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), |
| 50 | + CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| 51 | + LastModified = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false), |
| 52 | + LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| 53 | + Deleted = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true), |
| 54 | + DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true) |
| 55 | + }, |
| 56 | + constraints: table => |
| 57 | + { |
| 58 | + table.PrimaryKey("PK_Products", x => x.Id); |
| 59 | + table.ForeignKey( |
| 60 | + name: "FK_Products_Brands_BrandId", |
| 61 | + column: x => x.BrandId, |
| 62 | + principalSchema: "catalog", |
| 63 | + principalTable: "Brands", |
| 64 | + principalColumn: "Id"); |
| 65 | + }); |
| 66 | + |
| 67 | + migrationBuilder.CreateIndex( |
| 68 | + name: "IX_Products_BrandId", |
| 69 | + schema: "catalog", |
| 70 | + table: "Products", |
| 71 | + column: "BrandId"); |
| 72 | + } |
| 73 | + |
| 74 | + /// <inheritdoc /> |
| 75 | + protected override void Down(MigrationBuilder migrationBuilder) |
| 76 | + { |
| 77 | + migrationBuilder.DropTable( |
| 78 | + name: "Products", |
| 79 | + schema: "catalog"); |
| 80 | + |
| 81 | + migrationBuilder.DropTable( |
| 82 | + name: "Brands", |
| 83 | + schema: "catalog"); |
| 84 | + } |
| 85 | + } |
| 86 | +} |
0 commit comments