-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create new `TakenTrack` table * - update model - create migration * - remove `TakenTrackId` - update migration * - use `bool IsRefunded` instead of `enum TakenType` - update migration
- Loading branch information
Showing
6 changed files
with
390 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace DispenserProvider.DataBase.Models; | ||
|
||
public class TakenTrackDTO | ||
{ | ||
public long Id { get; set; } | ||
|
||
public bool IsRefunded { get; set; } | ||
|
||
[NotMapped] | ||
public bool IsWithdrawn => !IsRefunded; | ||
|
||
[Column(TypeName = "nvarchar(64)")] | ||
public string DispenserId { get; set; } = null!; | ||
|
||
public virtual DispenserDTO Dispenser { get; set; } = null!; | ||
} |
276 changes: 276 additions & 0 deletions
276
...ispenserProvider.Migrations/Migrations/20241230132757_Create-TakenTrack-Table.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
src/DispenserProvider.Migrations/Migrations/20241230132757_Create-TakenTrack-Table.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace DispenserProvider.DataBase.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class CreateTakenTrackTable : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "TakenTrack", | ||
columns: table => new | ||
{ | ||
Id = table.Column<long>(type: "bigint", nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
IsRefunded = table.Column<bool>(type: "bit", nullable: false), | ||
DispenserId = table.Column<string>(type: "nvarchar(64)", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_TakenTrack", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_TakenTrack_Dispenser_DispenserId", | ||
column: x => x.DispenserId, | ||
principalTable: "Dispenser", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Restrict); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_TakenTrack_DispenserId", | ||
table: "TakenTrack", | ||
column: "DispenserId", | ||
unique: true); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "TakenTrack"); | ||
} | ||
} | ||
} |
Oops, something went wrong.