using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace CartriX.Api.Migrations { /// public partial class Init1 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "PrinterConnectionType", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PrinterConnectionType", x => x.Id); }); migrationBuilder.CreateTable( name: "PrinterModel", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PrinterModel", x => x.Id); }); migrationBuilder.CreateTable( name: "StatusCartridges", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StatusCartridges", x => x.Id); }); migrationBuilder.CreateTable( name: "StatusPrinters", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StatusPrinters", x => x.Id); }); migrationBuilder.CreateTable( name: "SupportPrinterCartridges", columns: table => new { PrinterModelId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.ForeignKey( name: "FK_SupportPrinterCartridges_PrinterModel_PrinterModelId", column: x => x.PrinterModelId, principalTable: "PrinterModel", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Printers", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), PrinterName = table.Column(type: "TEXT", nullable: false), ModelId = table.Column(type: "INTEGER", nullable: false), PrinterConnectionTypeId = table.Column(type: "INTEGER", nullable: false), PrinterUsedPagesOID = table.Column(type: "TEXT", nullable: true), StatusId = table.Column(type: "INTEGER", nullable: false), IpAddress = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Printers", x => x.Id); table.ForeignKey( name: "FK_Printers_PrinterConnectionType_PrinterConnectionTypeId", column: x => x.PrinterConnectionTypeId, principalTable: "PrinterConnectionType", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Printers_PrinterModel_ModelId", column: x => x.ModelId, principalTable: "PrinterModel", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Printers_StatusPrinters_StatusId", column: x => x.StatusId, principalTable: "StatusPrinters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "CartridgeModel", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), PrinterId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_CartridgeModel", x => x.Id); table.ForeignKey( name: "FK_CartridgeModel_Printers_PrinterId", column: x => x.PrinterId, principalTable: "Printers", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Cartridges", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), ModelId = table.Column(type: "INTEGER", nullable: false), StatusId = table.Column(type: "INTEGER", nullable: false), Capacity = table.Column(type: "INTEGER", nullable: false), InPrinterId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Cartridges", x => x.Id); table.ForeignKey( name: "FK_Cartridges_CartridgeModel_ModelId", column: x => x.ModelId, principalTable: "CartridgeModel", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Cartridges_Printers_InPrinterId", column: x => x.InPrinterId, principalTable: "Printers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Cartridges_StatusCartridges_StatusId", column: x => x.StatusId, principalTable: "StatusCartridges", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "PrinterConnectionType", columns: new[] { "Id", "Name" }, values: new object[,] { { 1, "Network" }, { 2, "USB" } }); migrationBuilder.CreateIndex( name: "IX_CartridgeModel_PrinterId", table: "CartridgeModel", column: "PrinterId"); migrationBuilder.CreateIndex( name: "IX_Cartridges_InPrinterId", table: "Cartridges", column: "InPrinterId"); migrationBuilder.CreateIndex( name: "IX_Cartridges_ModelId", table: "Cartridges", column: "ModelId"); migrationBuilder.CreateIndex( name: "IX_Cartridges_StatusId", table: "Cartridges", column: "StatusId"); migrationBuilder.CreateIndex( name: "IX_Printers_ModelId", table: "Printers", column: "ModelId"); migrationBuilder.CreateIndex( name: "IX_Printers_PrinterConnectionTypeId", table: "Printers", column: "PrinterConnectionTypeId"); migrationBuilder.CreateIndex( name: "IX_Printers_StatusId", table: "Printers", column: "StatusId"); migrationBuilder.CreateIndex( name: "IX_SupportPrinterCartridges_PrinterModelId", table: "SupportPrinterCartridges", column: "PrinterModelId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Cartridges"); migrationBuilder.DropTable( name: "SupportPrinterCartridges"); migrationBuilder.DropTable( name: "CartridgeModel"); migrationBuilder.DropTable( name: "StatusCartridges"); migrationBuilder.DropTable( name: "Printers"); migrationBuilder.DropTable( name: "PrinterConnectionType"); migrationBuilder.DropTable( name: "PrinterModel"); migrationBuilder.DropTable( name: "StatusPrinters"); } } }