Files
barkman/barkmanAPI/Migrations/20260716020638_addoders.cs
T
2026-07-15 21:06:50 -05:00

99 lines
4.1 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace barkmanapi.Migrations
{
/// <inheritdoc />
public partial class addoders : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "order_status",
columns: table => new
{
id = table.Column<string>(type: "text", nullable: false),
name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_order_status", x => x.id);
});
migrationBuilder.CreateTable(
name: "orders",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
customer_id = table.Column<string>(type: "text", nullable: false),
name = table.Column<string>(type: "text", nullable: false),
status_id = table.Column<string>(type: "text", nullable: true),
start_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
end_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
total_price = table.Column<decimal>(type: "numeric", nullable: false),
venue = table.Column<string>(type: "text", nullable: true),
address = table.Column<string>(type: "text", nullable: true),
notes = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_orders", x => x.id);
table.ForeignKey(
name: "fk_orders_order_status_status_id",
column: x => x.status_id,
principalTable: "order_status",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "order_items",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
order_id = table.Column<string>(type: "text", nullable: false),
item_id = table.Column<string>(type: "text", nullable: false),
quantity = table.Column<int>(type: "integer", nullable: false),
orders_id = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_order_items", x => x.id);
table.ForeignKey(
name: "fk_order_items_orders_orders_id",
column: x => x.orders_id,
principalTable: "orders",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "ix_order_items_orders_id",
table: "order_items",
column: "orders_id");
migrationBuilder.CreateIndex(
name: "ix_orders_status_id",
table: "orders",
column: "status_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "order_items");
migrationBuilder.DropTable(
name: "orders");
migrationBuilder.DropTable(
name: "order_status");
}
}
}