Files
PyroFetes-Sujet1/PyroFetes/Migrations/20251008103414_InitialDatabase.cs

1393 lines
61 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PyroFetes.Migrations
{
/// <inheritdoc />
public partial class InitialDatabase : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Availabilities",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AvailabilityDate = table.Column<DateOnly>(type: "date", nullable: false),
DeliveryDate = table.Column<DateOnly>(type: "date", nullable: false),
ExpirationDate = table.Column<DateOnly>(type: "date", nullable: false),
RenewallDate = table.Column<DateOnly>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Availabilities", x => x.Id);
});
migrationBuilder.CreateTable(
name: "City",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
ZipCode = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_City", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Classifications",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Classifications", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Colors",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Colors", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CustomerTypes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CustomerTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Deliverers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Transporter = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Deliverers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Effects",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Effects", x => x.Id);
});
migrationBuilder.CreateTable(
name: "HistoryOfApprovals",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DeliveryDate = table.Column<DateOnly>(type: "date", nullable: false),
ExpirationDate = table.Column<DateOnly>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HistoryOfApprovals", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ProductCategories",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductCategories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ProviderTypes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProviderTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PurchaseOrders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PurchaseConditions = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseOrders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Settings",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Logo = table.Column<string>(type: "nvarchar(max)", nullable: false),
ElectronicSignature = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Settings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SoundCategories",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SoundCategories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Staffs",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
LastName = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
Profession = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Email = table.Column<string>(type: "nvarchar(120)", maxLength: 120, nullable: false),
F4T2NumberApproval = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
F4T2ExpirationDate = table.Column<DateOnly>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Staffs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Suppliers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Email = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Phone = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Address = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
ZipCode = table.Column<int>(type: "int", nullable: false),
City = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
DeliveryDelay = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Suppliers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Trucks",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Type = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
MaxExplosiveCapacity = table.Column<double>(type: "float", nullable: false),
Sizes = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
Status = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Trucks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Password = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Salt = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Email = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Fonction = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Warehouses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
MaxWeight = table.Column<int>(type: "int", nullable: false),
Current = table.Column<int>(type: "int", nullable: false),
MinWeight = table.Column<int>(type: "int", nullable: false),
Address = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
ZipCode = table.Column<int>(type: "int", nullable: false),
City = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Warehouses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Shows",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Place = table.Column<string>(type: "nvarchar(120)", maxLength: 120, nullable: false),
Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
Date = table.Column<DateOnly>(type: "date", nullable: true),
PyrotechnicImplementationPlan = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
CityId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Shows", x => x.Id);
table.ForeignKey(
name: "FK_Shows_City_CityId",
column: x => x.CityId,
principalTable: "City",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Note = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
CustomerTypeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
table.ForeignKey(
name: "FK_Customers_CustomerTypes_CustomerTypeId",
column: x => x.CustomerTypeId,
principalTable: "CustomerTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DeliveryNotes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TrackingNumber = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
DelivererId = table.Column<int>(type: "int", nullable: false),
EstimateDeliveryDate = table.Column<DateOnly>(type: "date", nullable: false),
ExpeditionDate = table.Column<DateOnly>(type: "date", nullable: false),
RealDeliveryDate = table.Column<DateOnly>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeliveryNotes", x => x.Id);
table.ForeignKey(
name: "FK_DeliveryNotes_Deliverers_DelivererId",
column: x => x.DelivererId,
principalTable: "Deliverers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Providers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
ProviderTypeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Providers", x => x.Id);
table.ForeignKey(
name: "FK_Providers_ProviderTypes_ProviderTypeId",
column: x => x.ProviderTypeId,
principalTable: "ProviderTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Sounds",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(120)", maxLength: 120, nullable: false),
Type = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
Artist = table.Column<string>(type: "nvarchar(120)", maxLength: 120, nullable: false),
Duration = table.Column<int>(type: "int", nullable: false),
Kind = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
Format = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: true),
SoundCategoryId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sounds", x => x.Id);
table.ForeignKey(
name: "FK_Sounds_SoundCategories_SoundCategoryId",
column: x => x.SoundCategoryId,
principalTable: "SoundCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ExperienceLevels",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Label = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
StaffId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExperienceLevels", x => x.Id);
table.ForeignKey(
name: "FK_ExperienceLevels_Staffs_StaffId",
column: x => x.StaffId,
principalTable: "Staffs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StaffAvailabilities",
columns: table => new
{
StaffId = table.Column<int>(type: "int", nullable: false),
AvailabilityId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StaffAvailabilities", x => new { x.AvailabilityId, x.StaffId });
table.ForeignKey(
name: "FK_StaffAvailabilities_Availabilities_AvailabilityId",
column: x => x.AvailabilityId,
principalTable: "Availabilities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StaffAvailabilities_Staffs_StaffId",
column: x => x.StaffId,
principalTable: "Staffs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StaffHistoryOfApprovals",
columns: table => new
{
StaffId = table.Column<int>(type: "int", nullable: false),
HistoryOfApprovalId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StaffHistoryOfApprovals", x => new { x.HistoryOfApprovalId, x.StaffId });
table.ForeignKey(
name: "FK_StaffHistoryOfApprovals_HistoryOfApprovals_HistoryOfApprovalId",
column: x => x.HistoryOfApprovalId,
principalTable: "HistoryOfApprovals",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StaffHistoryOfApprovals_Staffs_StaffId",
column: x => x.StaffId,
principalTable: "Staffs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Materials",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false),
WarehouseId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Materials", x => x.Id);
table.ForeignKey(
name: "FK_Materials_Warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "Warehouses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Movements",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
Start = table.Column<DateTime>(type: "datetime2", nullable: false),
Arrival = table.Column<DateTime>(type: "datetime2", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false),
SourceWarehouseId = table.Column<int>(type: "int", nullable: true),
DestinationWarehouseId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Movements", x => x.Id);
table.ForeignKey(
name: "FK_Movements_Warehouses_DestinationWarehouseId",
column: x => x.DestinationWarehouseId,
principalTable: "Warehouses",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Movements_Warehouses_SourceWarehouseId",
column: x => x.SourceWarehouseId,
principalTable: "Warehouses",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ShowStaff",
columns: table => new
{
StaffId = table.Column<int>(type: "int", nullable: false),
ShowId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShowStaff", x => new { x.StaffId, x.ShowId });
table.ForeignKey(
name: "FK_ShowStaff_Shows_ShowId",
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ShowStaff_Staffs_StaffId",
column: x => x.StaffId,
principalTable: "Staffs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ShowTruck",
columns: table => new
{
ShowId = table.Column<int>(type: "int", nullable: false),
TruckId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShowTruck", x => new { x.ShowId, x.TruckId });
table.ForeignKey(
name: "FK_ShowTruck_Shows_ShowId",
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ShowTruck_Trucks_TruckId",
column: x => x.TruckId,
principalTable: "Trucks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Contacts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
LastName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
FirstName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Email = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Address = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
ZipCode = table.Column<int>(type: "int", nullable: false),
City = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Role = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
CustomerId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Contacts", x => x.Id);
table.ForeignKey(
name: "FK_Contacts_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Quotations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Message = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
ConditionsSale = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: false),
CustomerId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Quotations", x => x.Id);
table.ForeignKey(
name: "FK_Quotations_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Contract",
columns: table => new
{
ShowId = table.Column<int>(type: "int", nullable: false),
ServiceProviderId = table.Column<int>(type: "int", nullable: false),
TermsAndConditions = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Contract", x => new { x.ShowId, x.ServiceProviderId });
table.ForeignKey(
name: "FK_Contract_Providers_ServiceProviderId",
column: x => x.ServiceProviderId,
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Contract_Shows_ShowId",
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "SoundTimecodes",
columns: table => new
{
ShowId = table.Column<int>(type: "int", nullable: false),
SoundId = table.Column<int>(type: "int", nullable: false),
Start = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
End = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SoundTimecodes", x => new { x.ShowId, x.SoundId });
table.ForeignKey(
name: "FK_SoundTimecodes_Shows_ShowId",
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SoundTimecodes_Sounds_SoundId",
column: x => x.SoundId,
principalTable: "Sounds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MaterialWarehouse",
columns: table => new
{
MaterialId = table.Column<int>(type: "int", nullable: false),
WarehouseId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MaterialWarehouse", x => new { x.MaterialId, x.WarehouseId });
table.ForeignKey(
name: "FK_MaterialWarehouse_Materials_MaterialId",
column: x => x.MaterialId,
principalTable: "Materials",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_MaterialWarehouse_Warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "Warehouses",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ShowMaterial",
columns: table => new
{
ShowId = table.Column<int>(type: "int", nullable: false),
MaterialId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShowMaterial", x => new { x.ShowId, x.MaterialId });
table.ForeignKey(
name: "FK_ShowMaterial_Materials_MaterialId",
column: x => x.MaterialId,
principalTable: "Materials",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ShowMaterial_Shows_ShowId",
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
References = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Duration = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Caliber = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
ApprovalNumber = table.Column<int>(type: "int", nullable: false),
Weight = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Nec = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
SellingPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Image = table.Column<string>(type: "nvarchar(max)", nullable: false),
Link = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
MinimalQuantity = table.Column<int>(type: "int", nullable: false),
ClassificationId = table.Column<int>(type: "int", nullable: false),
ProductCategoryId = table.Column<int>(type: "int", nullable: false),
MovementId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
table.ForeignKey(
name: "FK_Products_Classifications_ClassificationId",
column: x => x.ClassificationId,
principalTable: "Classifications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Products_Movements_MovementId",
column: x => x.MovementId,
principalTable: "Movements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Products_ProductCategories_ProductCategoryId",
column: x => x.ProductCategoryId,
principalTable: "ProductCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Communications",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Calling = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Email = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Meeting = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: false),
ContactId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Communications", x => x.Id);
table.ForeignKey(
name: "FK_Communications_Contacts_ContactId",
column: x => x.ContactId,
principalTable: "Contacts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ContactServiceProvider",
columns: table => new
{
ContactId = table.Column<int>(type: "int", nullable: false),
ServiceProviderId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ContactServiceProvider", x => new { x.ContactId, x.ServiceProviderId });
table.ForeignKey(
name: "FK_ContactServiceProvider_Contacts_ContactId",
column: x => x.ContactId,
principalTable: "Contacts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ContactServiceProvider_Providers_ServiceProviderId",
column: x => x.ServiceProviderId,
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProviderContacts",
columns: table => new
{
ProviderId = table.Column<int>(type: "int", nullable: false),
ContactId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProviderContacts", x => new { x.ContactId, x.ProviderId });
table.ForeignKey(
name: "FK_ProviderContacts_Contacts_ContactId",
column: x => x.ContactId,
principalTable: "Contacts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProviderContacts_Providers_ProviderId",
column: x => x.ProviderId,
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StaffContacts",
columns: table => new
{
StaffId = table.Column<int>(type: "int", nullable: false),
ContactId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StaffContacts", x => new { x.ContactId, x.StaffId });
table.ForeignKey(
name: "FK_StaffContacts_Contacts_ContactId",
column: x => x.ContactId,
principalTable: "Contacts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StaffContacts_Staffs_StaffId",
column: x => x.StaffId,
principalTable: "Staffs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Brands",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
ProductId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Brands", x => x.Id);
table.ForeignKey(
name: "FK_Brands_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Prices",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
SupplierId = table.Column<int>(type: "int", nullable: false),
SellingPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Prices", x => new { x.ProductId, x.SupplierId });
table.ForeignKey(
name: "FK_Prices_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Prices_Suppliers_SupplierId",
column: x => x.SupplierId,
principalTable: "Suppliers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductColors",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
ColorId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductColors", x => new { x.ProductId, x.ColorId });
table.ForeignKey(
name: "FK_ProductColors_Colors_ColorId",
column: x => x.ColorId,
principalTable: "Colors",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductColors_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductDeliveries",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
DeliveryNoteId = table.Column<int>(type: "int", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductDeliveries", x => new { x.ProductId, x.DeliveryNoteId });
table.ForeignKey(
name: "FK_ProductDeliveries_DeliveryNotes_DeliveryNoteId",
column: x => x.DeliveryNoteId,
principalTable: "DeliveryNotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductDeliveries_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductEffects",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
EffectId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductEffects", x => new { x.ProductId, x.EffectId });
table.ForeignKey(
name: "FK_ProductEffects_Effects_EffectId",
column: x => x.EffectId,
principalTable: "Effects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductEffects_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProductTimecode",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
ShowId = table.Column<int>(type: "int", nullable: false),
Start = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
End = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductTimecode", x => new { x.ProductId, x.ShowId });
table.ForeignKey(
name: "FK_ProductTimecode_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProductTimecode_Shows_ShowId",
column: x => x.ShowId,
principalTable: "Shows",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PurchaseProducts",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
PurchaseOrderId = table.Column<int>(type: "int", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseProducts", x => new { x.ProductId, x.PurchaseOrderId });
table.ForeignKey(
name: "FK_PurchaseProducts_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseProducts_PurchaseOrders_PurchaseOrderId",
column: x => x.PurchaseOrderId,
principalTable: "PurchaseOrders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "QuotationProducts",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
QuotationId = table.Column<int>(type: "int", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuotationProducts", x => new { x.ProductId, x.QuotationId });
table.ForeignKey(
name: "FK_QuotationProducts_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_QuotationProducts_Quotations_QuotationId",
column: x => x.QuotationId,
principalTable: "Quotations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "WarehouseProducts",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false),
WarehouseId = table.Column<int>(type: "int", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WarehouseProducts", x => new { x.ProductId, x.WarehouseId });
table.ForeignKey(
name: "FK_WarehouseProducts_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_WarehouseProducts_Warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "Warehouses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Brands_ProductId",
table: "Brands",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Communications_ContactId",
table: "Communications",
column: "ContactId");
migrationBuilder.CreateIndex(
name: "IX_Contacts_CustomerId",
table: "Contacts",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_ContactServiceProvider_ServiceProviderId",
table: "ContactServiceProvider",
column: "ServiceProviderId");
migrationBuilder.CreateIndex(
name: "IX_Contract_ServiceProviderId",
table: "Contract",
column: "ServiceProviderId");
migrationBuilder.CreateIndex(
name: "IX_Customers_CustomerTypeId",
table: "Customers",
column: "CustomerTypeId");
migrationBuilder.CreateIndex(
name: "IX_DeliveryNotes_DelivererId",
table: "DeliveryNotes",
column: "DelivererId");
migrationBuilder.CreateIndex(
name: "IX_ExperienceLevels_StaffId",
table: "ExperienceLevels",
column: "StaffId");
migrationBuilder.CreateIndex(
name: "IX_Materials_WarehouseId",
table: "Materials",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_MaterialWarehouse_WarehouseId",
table: "MaterialWarehouse",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_Movements_DestinationWarehouseId",
table: "Movements",
column: "DestinationWarehouseId");
migrationBuilder.CreateIndex(
name: "IX_Movements_SourceWarehouseId",
table: "Movements",
column: "SourceWarehouseId");
migrationBuilder.CreateIndex(
name: "IX_Prices_SupplierId",
table: "Prices",
column: "SupplierId");
migrationBuilder.CreateIndex(
name: "IX_ProductColors_ColorId",
table: "ProductColors",
column: "ColorId");
migrationBuilder.CreateIndex(
name: "IX_ProductDeliveries_DeliveryNoteId",
table: "ProductDeliveries",
column: "DeliveryNoteId");
migrationBuilder.CreateIndex(
name: "IX_ProductEffects_EffectId",
table: "ProductEffects",
column: "EffectId");
migrationBuilder.CreateIndex(
name: "IX_Products_ClassificationId",
table: "Products",
column: "ClassificationId");
migrationBuilder.CreateIndex(
name: "IX_Products_MovementId",
table: "Products",
column: "MovementId");
migrationBuilder.CreateIndex(
name: "IX_Products_ProductCategoryId",
table: "Products",
column: "ProductCategoryId");
migrationBuilder.CreateIndex(
name: "IX_ProductTimecode_ShowId",
table: "ProductTimecode",
column: "ShowId");
migrationBuilder.CreateIndex(
name: "IX_ProviderContacts_ProviderId",
table: "ProviderContacts",
column: "ProviderId");
migrationBuilder.CreateIndex(
name: "IX_Providers_ProviderTypeId",
table: "Providers",
column: "ProviderTypeId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseProducts_PurchaseOrderId",
table: "PurchaseProducts",
column: "PurchaseOrderId");
migrationBuilder.CreateIndex(
name: "IX_QuotationProducts_QuotationId",
table: "QuotationProducts",
column: "QuotationId");
migrationBuilder.CreateIndex(
name: "IX_Quotations_CustomerId",
table: "Quotations",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_ShowMaterial_MaterialId",
table: "ShowMaterial",
column: "MaterialId");
migrationBuilder.CreateIndex(
name: "IX_Shows_CityId",
table: "Shows",
column: "CityId");
migrationBuilder.CreateIndex(
name: "IX_ShowStaff_ShowId",
table: "ShowStaff",
column: "ShowId");
migrationBuilder.CreateIndex(
name: "IX_ShowTruck_TruckId",
table: "ShowTruck",
column: "TruckId");
migrationBuilder.CreateIndex(
name: "IX_Sounds_SoundCategoryId",
table: "Sounds",
column: "SoundCategoryId");
migrationBuilder.CreateIndex(
name: "IX_SoundTimecodes_SoundId",
table: "SoundTimecodes",
column: "SoundId");
migrationBuilder.CreateIndex(
name: "IX_StaffAvailabilities_StaffId",
table: "StaffAvailabilities",
column: "StaffId");
migrationBuilder.CreateIndex(
name: "IX_StaffContacts_StaffId",
table: "StaffContacts",
column: "StaffId");
migrationBuilder.CreateIndex(
name: "IX_StaffHistoryOfApprovals_StaffId",
table: "StaffHistoryOfApprovals",
column: "StaffId");
migrationBuilder.CreateIndex(
name: "IX_WarehouseProducts_WarehouseId",
table: "WarehouseProducts",
column: "WarehouseId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Brands");
migrationBuilder.DropTable(
name: "Communications");
migrationBuilder.DropTable(
name: "ContactServiceProvider");
migrationBuilder.DropTable(
name: "Contract");
migrationBuilder.DropTable(
name: "ExperienceLevels");
migrationBuilder.DropTable(
name: "MaterialWarehouse");
migrationBuilder.DropTable(
name: "Prices");
migrationBuilder.DropTable(
name: "ProductColors");
migrationBuilder.DropTable(
name: "ProductDeliveries");
migrationBuilder.DropTable(
name: "ProductEffects");
migrationBuilder.DropTable(
name: "ProductTimecode");
migrationBuilder.DropTable(
name: "ProviderContacts");
migrationBuilder.DropTable(
name: "PurchaseProducts");
migrationBuilder.DropTable(
name: "QuotationProducts");
migrationBuilder.DropTable(
name: "Settings");
migrationBuilder.DropTable(
name: "ShowMaterial");
migrationBuilder.DropTable(
name: "ShowStaff");
migrationBuilder.DropTable(
name: "ShowTruck");
migrationBuilder.DropTable(
name: "SoundTimecodes");
migrationBuilder.DropTable(
name: "StaffAvailabilities");
migrationBuilder.DropTable(
name: "StaffContacts");
migrationBuilder.DropTable(
name: "StaffHistoryOfApprovals");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "WarehouseProducts");
migrationBuilder.DropTable(
name: "Suppliers");
migrationBuilder.DropTable(
name: "Colors");
migrationBuilder.DropTable(
name: "DeliveryNotes");
migrationBuilder.DropTable(
name: "Effects");
migrationBuilder.DropTable(
name: "Providers");
migrationBuilder.DropTable(
name: "PurchaseOrders");
migrationBuilder.DropTable(
name: "Quotations");
migrationBuilder.DropTable(
name: "Materials");
migrationBuilder.DropTable(
name: "Trucks");
migrationBuilder.DropTable(
name: "Shows");
migrationBuilder.DropTable(
name: "Sounds");
migrationBuilder.DropTable(
name: "Availabilities");
migrationBuilder.DropTable(
name: "Contacts");
migrationBuilder.DropTable(
name: "HistoryOfApprovals");
migrationBuilder.DropTable(
name: "Staffs");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Deliverers");
migrationBuilder.DropTable(
name: "ProviderTypes");
migrationBuilder.DropTable(
name: "City");
migrationBuilder.DropTable(
name: "SoundCategories");
migrationBuilder.DropTable(
name: "Customers");
migrationBuilder.DropTable(
name: "Classifications");
migrationBuilder.DropTable(
name: "Movements");
migrationBuilder.DropTable(
name: "ProductCategories");
migrationBuilder.DropTable(
name: "CustomerTypes");
migrationBuilder.DropTable(
name: "Warehouses");
}
}
}