69 lines
2.6 KiB
C#
69 lines
2.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class cartitem : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "DatePurchase",
|
|
table: "Purchases",
|
|
type: "timestamp without time zone",
|
|
nullable: true,
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "timestamp without time zone");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CartItems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false),
|
|
Cost = table.Column<double>(type: "double precision", nullable: false),
|
|
DateCreated = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductName = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CartItems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CartItems_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CartItems_ProductId",
|
|
table: "CartItems",
|
|
column: "ProductId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CartItems");
|
|
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "DatePurchase",
|
|
table: "Purchases",
|
|
type: "timestamp without time zone",
|
|
nullable: false,
|
|
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "timestamp without time zone",
|
|
oldNullable: true);
|
|
}
|
|
}
|
|
}
|