using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BudgetApp.Migrations { /// public partial class AddSalary : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "SalaryId", table: "Transactions", type: "INTEGER", nullable: true); migrationBuilder.CreateTable( name: "Salaries", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", maxLength: 200, nullable: false), Amount = table.Column(type: "decimal(18,2)", nullable: false), RecurrenceType = table.Column(type: "INTEGER", nullable: false), StartDate = table.Column(type: "TEXT", nullable: false), AccountId = table.Column(type: "INTEGER", nullable: false), CategoryId = table.Column(type: "INTEGER", nullable: true), UserId = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Salaries", x => x.Id); table.ForeignKey( name: "FK_Salaries_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Salaries_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Salaries_Categories_CategoryId", column: x => x.CategoryId, principalTable: "Categories", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Transactions_SalaryId", table: "Transactions", column: "SalaryId"); migrationBuilder.CreateIndex( name: "IX_Salaries_AccountId", table: "Salaries", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_Salaries_CategoryId", table: "Salaries", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_Salaries_UserId", table: "Salaries", column: "UserId"); migrationBuilder.AddForeignKey( name: "FK_Transactions_Salaries_SalaryId", table: "Transactions", column: "SalaryId", principalTable: "Salaries", principalColumn: "Id", onDelete: ReferentialAction.SetNull); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Transactions_Salaries_SalaryId", table: "Transactions"); migrationBuilder.DropTable( name: "Salaries"); migrationBuilder.DropIndex( name: "IX_Transactions_SalaryId", table: "Transactions"); migrationBuilder.DropColumn( name: "SalaryId", table: "Transactions"); } } }