2024-08-17 16:38:40 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
|
|
namespace Vegasco.WebApi.Persistence.Migrations
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <inheritdoc />
|
2024-08-17 18:00:23 +02:00
|
|
|
|
public partial class Initial : Migration
|
2024-08-17 16:38:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
|
{
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
|
name: "Users",
|
|
|
|
|
|
columns: table => new
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = table.Column<string>(type: "text", nullable: false)
|
|
|
|
|
|
},
|
|
|
|
|
|
constraints: table =>
|
|
|
|
|
|
{
|
|
|
|
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
|
name: "Cars",
|
|
|
|
|
|
columns: table => new
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
|
|
|
|
Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
|
|
|
|
UserId = table.Column<string>(type: "text", nullable: false)
|
|
|
|
|
|
},
|
|
|
|
|
|
constraints: table =>
|
|
|
|
|
|
{
|
|
|
|
|
|
table.PrimaryKey("PK_Cars", x => x.Id);
|
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
|
name: "FK_Cars_Users_UserId",
|
|
|
|
|
|
column: x => x.UserId,
|
|
|
|
|
|
principalTable: "Users",
|
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-08-17 18:00:23 +02:00
|
|
|
|
migrationBuilder.CreateTable(
|
2024-08-23 18:02:18 +02:00
|
|
|
|
name: "Consumptions",
|
2024-08-17 18:00:23 +02:00
|
|
|
|
columns: table => new
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
|
|
|
|
DateTime = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
|
|
|
|
Distance = table.Column<double>(type: "double precision", nullable: false),
|
|
|
|
|
|
Amount = table.Column<double>(type: "double precision", nullable: false),
|
|
|
|
|
|
IgnoreInCalculation = table.Column<bool>(type: "boolean", nullable: false),
|
|
|
|
|
|
CarId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
|
|
|
|
},
|
|
|
|
|
|
constraints: table =>
|
|
|
|
|
|
{
|
2024-08-23 18:02:18 +02:00
|
|
|
|
table.PrimaryKey("PK_Consumptions", x => x.Id);
|
2024-08-17 18:00:23 +02:00
|
|
|
|
table.ForeignKey(
|
2024-08-23 18:02:18 +02:00
|
|
|
|
name: "FK_Consumptions_Cars_CarId",
|
2024-08-17 18:00:23 +02:00
|
|
|
|
column: x => x.CarId,
|
|
|
|
|
|
principalTable: "Cars",
|
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-08-17 16:38:40 +02:00
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
|
name: "IX_Cars_UserId",
|
|
|
|
|
|
table: "Cars",
|
|
|
|
|
|
column: "UserId");
|
2024-08-17 18:00:23 +02:00
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2024-08-23 18:02:18 +02:00
|
|
|
|
name: "IX_Consumptions_CarId",
|
|
|
|
|
|
table: "Consumptions",
|
2024-08-17 18:00:23 +02:00
|
|
|
|
column: "CarId");
|
2024-08-17 16:38:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
|
{
|
2024-08-17 18:00:23 +02:00
|
|
|
|
migrationBuilder.DropTable(
|
2024-08-23 18:02:18 +02:00
|
|
|
|
name: "Consumptions");
|
2024-08-17 18:00:23 +02:00
|
|
|
|
|
2024-08-17 16:38:40 +02:00
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
|
name: "Cars");
|
|
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
|
name: "Users");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|