mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-08-11 11:42:03 +00:00
177 lines
7.6 KiB
C#
177 lines
7.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace barkmanapi.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class changedOrderToJob : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "order_items");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "order_status");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "job_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_job_status", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "jobs",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
customer_id = table.Column<int>(type: "integer", 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_jobs", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_jobs_job_status_status_id",
|
|
column: x => x.status_id,
|
|
principalTable: "job_status",
|
|
principalColumn: "id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "job_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),
|
|
jobs_id = table.Column<int>(type: "integer", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_job_items", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_job_items_jobs_jobs_id",
|
|
column: x => x.jobs_id,
|
|
principalTable: "jobs",
|
|
principalColumn: "id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_job_items_jobs_id",
|
|
table: "job_items",
|
|
column: "jobs_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_jobs_status_id",
|
|
table: "jobs",
|
|
column: "status_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "job_items");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "jobs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "job_status");
|
|
|
|
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),
|
|
status_id = table.Column<string>(type: "text", nullable: true),
|
|
address = table.Column<string>(type: "text", nullable: true),
|
|
customer_id = table.Column<int>(type: "integer", nullable: false),
|
|
end_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
name = table.Column<string>(type: "text", nullable: false),
|
|
notes = table.Column<string>(type: "text", nullable: true),
|
|
start_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)
|
|
},
|
|
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),
|
|
item_id = table.Column<string>(type: "text", nullable: false),
|
|
order_id = table.Column<string>(type: "text", nullable: false),
|
|
orders_id = table.Column<int>(type: "integer", nullable: true),
|
|
quantity = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
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");
|
|
}
|
|
}
|
|
}
|