using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
///
public partial class cartitem : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn(
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(type: "uuid", nullable: false),
UserId = table.Column(type: "uuid", nullable: false),
Count = table.Column(type: "integer", nullable: false),
Cost = table.Column(type: "double precision", nullable: false),
DateCreated = table.Column(type: "timestamp without time zone", nullable: false),
ProductId = table.Column(type: "uuid", nullable: false),
ProductName = table.Column(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");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CartItems");
migrationBuilder.AlterColumn(
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);
}
}
}