using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace DiunaBI.Infrastructure.Migrations { /// public partial class RenameModels : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DataRows"); migrationBuilder.DropTable( name: "DataSets"); migrationBuilder.CreateTable( name: "Layers", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Number = table.Column(type: "int", nullable: false), Source = table.Column(type: "nvarchar(max)", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), ModifiedAt = table.Column(type: "datetime2", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false), CreatedById = table.Column(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Layers", x => x.Id); table.ForeignKey( name: "FK_Layers_Users_CreatedById", column: x => x.CreatedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_Layers_Users_ModifiedById", column: x => x.ModifiedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( name: "Records", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Code = table.Column(type: "nvarchar(max)", nullable: false), Value = table.Column(type: "real", nullable: false), Desc1 = table.Column(type: "nvarchar(max)", nullable: true), Desc2 = table.Column(type: "nvarchar(max)", nullable: true), Desc3 = table.Column(type: "nvarchar(max)", nullable: true), Desc4 = table.Column(type: "nvarchar(max)", nullable: true), Desc5 = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), ModifiedAt = table.Column(type: "datetime2", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false), CreatedById = table.Column(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), LayerId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Records", x => x.Id); table.ForeignKey( name: "FK_Records_Layers_LayerId", column: x => x.LayerId, principalTable: "Layers", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_Records_Users_CreatedById", column: x => x.CreatedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_Records_Users_ModifiedById", column: x => x.ModifiedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateIndex( name: "IX_Layers_CreatedById", table: "Layers", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_Layers_ModifiedById", table: "Layers", column: "ModifiedById"); migrationBuilder.CreateIndex( name: "IX_Records_CreatedById", table: "Records", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_Records_LayerId", table: "Records", column: "LayerId"); migrationBuilder.CreateIndex( name: "IX_Records_ModifiedById", table: "Records", column: "ModifiedById"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Records"); migrationBuilder.DropTable( name: "Layers"); migrationBuilder.CreateTable( name: "DataSets", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), CreatedById = table.Column(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false), ModifiedAt = table.Column(type: "datetime2", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Number = table.Column(type: "int", nullable: false), Source = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DataSets", x => x.Id); table.ForeignKey( name: "FK_DataSets_Users_CreatedById", column: x => x.CreatedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_DataSets_Users_ModifiedById", column: x => x.ModifiedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( name: "DataRows", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), CreatedById = table.Column(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), Code = table.Column(type: "nvarchar(max)", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), DataSetId = table.Column(type: "uniqueidentifier", nullable: false), Desc1 = table.Column(type: "nvarchar(max)", nullable: true), Desc2 = table.Column(type: "nvarchar(max)", nullable: true), Desc3 = table.Column(type: "nvarchar(max)", nullable: true), Desc4 = table.Column(type: "nvarchar(max)", nullable: true), Desc5 = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), ModifiedAt = table.Column(type: "datetime2", nullable: false), Value = table.Column(type: "real", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DataRows", x => x.Id); table.ForeignKey( name: "FK_DataRows_DataSets_DataSetId", column: x => x.DataSetId, principalTable: "DataSets", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_DataRows_Users_CreatedById", column: x => x.CreatedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_DataRows_Users_ModifiedById", column: x => x.ModifiedById, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateIndex( name: "IX_DataRows_CreatedById", table: "DataRows", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_DataRows_DataSetId", table: "DataRows", column: "DataSetId"); migrationBuilder.CreateIndex( name: "IX_DataRows_ModifiedById", table: "DataRows", column: "ModifiedById"); migrationBuilder.CreateIndex( name: "IX_DataSets_CreatedById", table: "DataSets", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_DataSets_ModifiedById", table: "DataSets", column: "ModifiedById"); } } }