AutoCatAvalonia/AutoCatCore/Migrations/20240508141817_InitialCreate.cs

352 lines
16 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AutoCatCore.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Email = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Token = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
FirebaseIdToken = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
FirebaseRefreshToken = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Email);
});
migrationBuilder.CreateTable(
name: "VehicleEngine",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Number = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Volume = table.Column<int>(type: "INTEGER", nullable: true),
PowerKw = table.Column<double>(type: "REAL", nullable: true),
PowerHp = table.Column<double>(type: "REAL", nullable: true),
FuelType = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleEngine", x => x.Id);
});
migrationBuilder.CreateTable(
name: "VehicleName",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Original = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Normalized = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleName", x => x.Id);
});
migrationBuilder.CreateTable(
name: "VehicleBrand",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NameId = table.Column<int>(type: "INTEGER", nullable: true),
Logo = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleBrand", x => x.Id);
table.ForeignKey(
name: "FK_VehicleBrand_VehicleName_NameId",
column: x => x.NameId,
principalTable: "VehicleName",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "VehicleModel",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NameId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleModel", x => x.Id);
table.ForeignKey(
name: "FK_VehicleModel_VehicleName_NameId",
column: x => x.NameId,
principalTable: "VehicleName",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Vehicles",
columns: table => new
{
Number = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
CurrentNumber = table.Column<string>(type: "TEXT", maxLength: 10, nullable: true),
Vin1 = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Vin2 = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Sts = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Pts = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
BrandId = table.Column<int>(type: "INTEGER", nullable: true),
ModelId = table.Column<int>(type: "INTEGER", nullable: true),
Color = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Year = table.Column<int>(type: "INTEGER", nullable: true),
Category = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
IsRightWheel = table.Column<bool>(type: "INTEGER", nullable: true),
IsJapanese = table.Column<bool>(type: "INTEGER", nullable: true),
AddedDate = table.Column<double>(type: "REAL", nullable: true),
UpdatedDate = table.Column<double>(type: "REAL", nullable: true),
AddedBy = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
EngineId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Vehicles", x => x.Number);
table.ForeignKey(
name: "FK_Vehicles_VehicleBrand_BrandId",
column: x => x.BrandId,
principalTable: "VehicleBrand",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Vehicles_VehicleEngine_EngineId",
column: x => x.EngineId,
principalTable: "VehicleEngine",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Vehicles_VehicleModel_ModelId",
column: x => x.ModelId,
principalTable: "VehicleModel",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Osago",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Number = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Date = table.Column<double>(type: "REAL", nullable: true),
Vin = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
PlateNumber = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Status = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Restrictions = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Insurant = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Owner = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
UsageRegion = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Osago", x => x.Id);
table.ForeignKey(
name: "FK_Osago_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehicleAd",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Url = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true),
Price = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Date = table.Column<double>(type: "REAL", maxLength: 50, nullable: true),
Mileage = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Region = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
City = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
AdDescription = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Photos = table.Column<string>(type: "TEXT", nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleAd", x => x.Id);
table.ForeignKey(
name: "FK_VehicleAd_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehicleEvent",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Date = table.Column<double>(type: "REAL", nullable: true),
Latitude = table.Column<double>(type: "REAL", nullable: true),
Longitude = table.Column<double>(type: "REAL", nullable: true),
Address = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleEvent", x => x.Id);
table.ForeignKey(
name: "FK_VehicleEvent_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehicleOwnershipPeriod",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
LastOperation = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
OwnerType = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
From = table.Column<long>(type: "INTEGER", nullable: true),
To = table.Column<long>(type: "INTEGER", nullable: true),
Region = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
RegistrationRegion = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
Locality = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Code = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Street = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Building = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Inn = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleOwnershipPeriod", x => x.Id);
table.ForeignKey(
name: "FK_VehicleOwnershipPeriod_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehiclePhoto",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Brand = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Model = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Date = table.Column<double>(type: "REAL", nullable: true),
Url = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehiclePhoto", x => x.Id);
table.ForeignKey(
name: "FK_VehiclePhoto_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateIndex(
name: "IX_Osago_VehicleNumber",
table: "Osago",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehicleAd_VehicleNumber",
table: "VehicleAd",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehicleBrand_NameId",
table: "VehicleBrand",
column: "NameId");
migrationBuilder.CreateIndex(
name: "IX_VehicleEvent_VehicleNumber",
table: "VehicleEvent",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehicleModel_NameId",
table: "VehicleModel",
column: "NameId");
migrationBuilder.CreateIndex(
name: "IX_VehicleOwnershipPeriod_VehicleNumber",
table: "VehicleOwnershipPeriod",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehiclePhoto_VehicleNumber",
table: "VehiclePhoto",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_Vehicles_BrandId",
table: "Vehicles",
column: "BrandId");
migrationBuilder.CreateIndex(
name: "IX_Vehicles_EngineId",
table: "Vehicles",
column: "EngineId");
migrationBuilder.CreateIndex(
name: "IX_Vehicles_ModelId",
table: "Vehicles",
column: "ModelId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Osago");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "VehicleAd");
migrationBuilder.DropTable(
name: "VehicleEvent");
migrationBuilder.DropTable(
name: "VehicleOwnershipPeriod");
migrationBuilder.DropTable(
name: "VehiclePhoto");
migrationBuilder.DropTable(
name: "Vehicles");
migrationBuilder.DropTable(
name: "VehicleBrand");
migrationBuilder.DropTable(
name: "VehicleEngine");
migrationBuilder.DropTable(
name: "VehicleModel");
migrationBuilder.DropTable(
name: "VehicleName");
}
}
}