222 lines
8.7 KiB
C#
222 lines
8.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class second : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<bool>(
|
|
name: "OnlyImportantMails",
|
|
table: "Users",
|
|
type: "boolean",
|
|
nullable: false,
|
|
defaultValue: false);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "MediaFiles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Location = table.Column<string>(type: "text", nullable: false),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MediaFiles", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Products",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|
Rate = table.Column<double>(type: "double precision", nullable: false),
|
|
IsBeingSold = table.Column<bool>(type: "boolean", nullable: false),
|
|
Amount = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Products", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Purchases",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
DatePurchase = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Purchases", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Sells",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
DateSell = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Sells", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Suppliers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Deals = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Suppliers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SupplierProducts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
SupplierId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SupplierProducts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SupplierProducts_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_SupplierProducts_Suppliers_SupplierId",
|
|
column: x => x.SupplierId,
|
|
principalTable: "Suppliers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Supplies",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Price = table.Column<double>(type: "double precision", nullable: false),
|
|
SupplierId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Supplies", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Supplies_Suppliers_SupplierId",
|
|
column: x => x.SupplierId,
|
|
principalTable: "Suppliers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SupplyProducts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
SupplyId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SupplyProducts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SupplyProducts_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_SupplyProducts_Supplies_SupplyId",
|
|
column: x => x.SupplyId,
|
|
principalTable: "Supplies",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SupplierProducts_ProductId",
|
|
table: "SupplierProducts",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SupplierProducts_SupplierId",
|
|
table: "SupplierProducts",
|
|
column: "SupplierId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Supplies_SupplierId",
|
|
table: "Supplies",
|
|
column: "SupplierId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SupplyProducts_ProductId",
|
|
table: "SupplyProducts",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SupplyProducts_SupplyId",
|
|
table: "SupplyProducts",
|
|
column: "SupplyId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "MediaFiles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Purchases");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Sells");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SupplierProducts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SupplyProducts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Products");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Supplies");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Suppliers");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "OnlyImportantMails",
|
|
table: "Users");
|
|
}
|
|
}
|
|
}
|