/*
  Warnings:

  - You are about to drop the column `version` on the `Document` table. All the data in the column will be lost.
  - The `status` column on the `Document` table would be dropped and recreated. This will lead to data loss if there is data in the column.
  - You are about to drop the column `changes` on the `DocumentVersion` table. All the data in the column will be lost.
  - You are about to drop the column `version` on the `DocumentVersion` table. All the data in the column will be lost.
  - You are about to drop the `Account` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Aircraft` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `AircraftDocument` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `AircraftLocation` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `AircraftSpecification` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `AirworthinessDirective` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Component` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ComponentDocument` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ComponentInstallation` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ComponentMaintenance` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Counter` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `CrewLog` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Department` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `EngineLog` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `FlightDefect` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `FlightLog` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `InventoryItem` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `KnowledgeArticle` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `KnowledgeAttachment` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `KnowledgeReview` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `KnowledgeTag` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `LRUHistory` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `LRUTracking` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `LoadEntry` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `LoadStation` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `LoadTemplate` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `LoadTemplateEntry` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceAssignment` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceChecklist` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceHistory` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceLog` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceLogPart` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceRecord` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceResource` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceSchedule` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceStatus` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `MaintenanceTask` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Notification` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PilotLog` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseOrder` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseOrderAttachment` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseOrderItem` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseRequest` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseRequestApproval` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseRequestAttachment` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `PurchaseRequestItem` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `QualityInspection` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Receipt` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ReceiptItem` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Report` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `RequiredPart` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `RequiredTool` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ResourceAvailability` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ResourceCertification` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ResourceSkill` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ServiceBulletin` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Staff` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `StockMovement` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Subtask` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `TaskAttachment` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `TaskSignoff` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Tool` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ToolCheckout` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ToolDocument` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `ToolLocationHistory` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Vendor` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `VendorContact` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `VendorDocument` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `VendorPerformance` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `VerificationToken` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `WeightBalanceCalculation` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `WeightBalanceConfig` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `WeightBalanceDocument` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `WorkOrder` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `WorkOrderAttachment` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `WorkOrderHistory` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_AircraftToAirworthinessDirective` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_AircraftToKnowledgeArticle` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_AircraftToServiceBulletin` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_AssignedStaff` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_ComponentToKnowledgeArticle` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_KnowledgeArticleToKnowledgeTag` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `_StaffWorkOrders` table. If the table is not empty, all the data it contains will be lost.
  - A unique constraint covering the columns `[documentId,userId]` on the table `DocumentPermission` will be added. If there are existing duplicate values, this will fail.
  - Changed the type of `type` on the `Document` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
  - Changed the type of `role` on the `DocumentPermission` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
  - Added the required column `versionNumber` to the `DocumentVersion` table without a default value. This is not possible if the table is not empty.
  - Added the required column `createdById` to the `DocumentWorkflow` table without a default value. This is not possible if the table is not empty.
  - Added the required column `type` to the `DocumentWorkflow` table without a default value. This is not possible if the table is not empty.
  - Made the column `dueDate` on table `DocumentWorkflow` required. This step will fail if there are existing NULL values in that column.
  - Changed the type of `status` on the `DocumentWorkflow` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.

*/
-- CreateEnum
CREATE TYPE "DmsDocumentStatus" AS ENUM ('DRAFT', 'UNDER_REVIEW', 'ACTIVE', 'ARCHIVED');

-- CreateEnum
CREATE TYPE "DmsDocumentType" AS ENUM ('TECHNICAL', 'REGULATORY', 'MAINTENANCE', 'OPERATIONS', 'TRAINING', 'OTHER');

-- DropForeignKey
ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey";

-- DropForeignKey
ALTER TABLE "AircraftDocument" DROP CONSTRAINT "AircraftDocument_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "AircraftLocation" DROP CONSTRAINT "AircraftLocation_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "AircraftSpecification" DROP CONSTRAINT "AircraftSpecification_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "AirworthinessDirective" DROP CONSTRAINT "AirworthinessDirective_createdById_fkey";

-- DropForeignKey
ALTER TABLE "AirworthinessDirective" DROP CONSTRAINT "AirworthinessDirective_updatedById_fkey";

-- DropForeignKey
ALTER TABLE "Component" DROP CONSTRAINT "Component_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "Component" DROP CONSTRAINT "Component_currentInstallationId_fkey";

-- DropForeignKey
ALTER TABLE "ComponentDocument" DROP CONSTRAINT "ComponentDocument_componentId_fkey";

-- DropForeignKey
ALTER TABLE "ComponentInstallation" DROP CONSTRAINT "ComponentInstallation_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "ComponentInstallation" DROP CONSTRAINT "ComponentInstallation_componentId_fkey";

-- DropForeignKey
ALTER TABLE "ComponentMaintenance" DROP CONSTRAINT "ComponentMaintenance_componentId_fkey";

-- DropForeignKey
ALTER TABLE "CrewLog" DROP CONSTRAINT "CrewLog_crewId_fkey";

-- DropForeignKey
ALTER TABLE "CrewLog" DROP CONSTRAINT "CrewLog_flightLogId_fkey";

-- DropForeignKey
ALTER TABLE "Document" DROP CONSTRAINT "Document_createdById_fkey";

-- DropForeignKey
ALTER TABLE "DocumentAuditLog" DROP CONSTRAINT "DocumentAuditLog_userId_fkey";

-- DropForeignKey
ALTER TABLE "DocumentPermission" DROP CONSTRAINT "DocumentPermission_userId_fkey";

-- DropForeignKey
ALTER TABLE "DocumentVersion" DROP CONSTRAINT "DocumentVersion_createdById_fkey";

-- DropForeignKey
ALTER TABLE "DocumentWorkflow" DROP CONSTRAINT "DocumentWorkflow_assignedToId_fkey";

-- DropForeignKey
ALTER TABLE "EngineLog" DROP CONSTRAINT "EngineLog_flightLogId_fkey";

-- DropForeignKey
ALTER TABLE "FlightDefect" DROP CONSTRAINT "FlightDefect_flightLogId_fkey";

-- DropForeignKey
ALTER TABLE "FlightLog" DROP CONSTRAINT "FlightLog_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "KnowledgeArticle" DROP CONSTRAINT "KnowledgeArticle_userId_fkey";

-- DropForeignKey
ALTER TABLE "KnowledgeAttachment" DROP CONSTRAINT "KnowledgeAttachment_articleId_fkey";

-- DropForeignKey
ALTER TABLE "KnowledgeAttachment" DROP CONSTRAINT "KnowledgeAttachment_uploadedBy_fkey";

-- DropForeignKey
ALTER TABLE "KnowledgeReview" DROP CONSTRAINT "KnowledgeReview_articleId_fkey";

-- DropForeignKey
ALTER TABLE "KnowledgeReview" DROP CONSTRAINT "KnowledgeReview_userId_fkey";

-- DropForeignKey
ALTER TABLE "LRUHistory" DROP CONSTRAINT "LRUHistory_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "LRUHistory" DROP CONSTRAINT "LRUHistory_lruId_fkey";

-- DropForeignKey
ALTER TABLE "LRUTracking" DROP CONSTRAINT "LRUTracking_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "LRUTracking" DROP CONSTRAINT "LRUTracking_itemId_fkey";

-- DropForeignKey
ALTER TABLE "LoadEntry" DROP CONSTRAINT "LoadEntry_calculationId_fkey";

-- DropForeignKey
ALTER TABLE "LoadEntry" DROP CONSTRAINT "LoadEntry_stationId_fkey";

-- DropForeignKey
ALTER TABLE "LoadStation" DROP CONSTRAINT "LoadStation_configId_fkey";

-- DropForeignKey
ALTER TABLE "LoadTemplateEntry" DROP CONSTRAINT "LoadTemplateEntry_templateId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceAssignment" DROP CONSTRAINT "MaintenanceAssignment_createdById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceAssignment" DROP CONSTRAINT "MaintenanceAssignment_resourceId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceAssignment" DROP CONSTRAINT "MaintenanceAssignment_taskId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceAssignment" DROP CONSTRAINT "MaintenanceAssignment_updatedById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceChecklist" DROP CONSTRAINT "MaintenanceChecklist_signedById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceChecklist" DROP CONSTRAINT "MaintenanceChecklist_taskId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceHistory" DROP CONSTRAINT "MaintenanceHistory_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceLog" DROP CONSTRAINT "MaintenanceLog_createdById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceLog" DROP CONSTRAINT "MaintenanceLog_taskId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceLogPart" DROP CONSTRAINT "MaintenanceLogPart_logId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceRecord" DROP CONSTRAINT "MaintenanceRecord_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceRecord" DROP CONSTRAINT "MaintenanceRecord_componentId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceRecord" DROP CONSTRAINT "MaintenanceRecord_createdById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceRecord" DROP CONSTRAINT "MaintenanceRecord_updatedById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceResource" DROP CONSTRAINT "MaintenanceResource_createdById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceResource" DROP CONSTRAINT "MaintenanceResource_updatedById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceSchedule" DROP CONSTRAINT "MaintenanceSchedule_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceSchedule" DROP CONSTRAINT "MaintenanceSchedule_createdById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceStatus" DROP CONSTRAINT "MaintenanceStatus_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_assignedUserId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_componentId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_createdById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_supervisorId_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_updatedById_fkey";

-- DropForeignKey
ALTER TABLE "MaintenanceTask" DROP CONSTRAINT "MaintenanceTask_workOrderId_fkey";

-- DropForeignKey
ALTER TABLE "PilotLog" DROP CONSTRAINT "PilotLog_flightLogId_fkey";

-- DropForeignKey
ALTER TABLE "PilotLog" DROP CONSTRAINT "PilotLog_pilotId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseOrder" DROP CONSTRAINT "PurchaseOrder_requestId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseOrder" DROP CONSTRAINT "PurchaseOrder_vendorId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseOrderAttachment" DROP CONSTRAINT "PurchaseOrderAttachment_orderId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseOrderItem" DROP CONSTRAINT "PurchaseOrderItem_orderId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseOrderItem" DROP CONSTRAINT "PurchaseOrderItem_requestItemId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseRequest" DROP CONSTRAINT "PurchaseRequest_departmentId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseRequest" DROP CONSTRAINT "PurchaseRequest_requesterId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseRequestApproval" DROP CONSTRAINT "PurchaseRequestApproval_approverId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseRequestApproval" DROP CONSTRAINT "PurchaseRequestApproval_requestId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseRequestAttachment" DROP CONSTRAINT "PurchaseRequestAttachment_requestId_fkey";

-- DropForeignKey
ALTER TABLE "PurchaseRequestItem" DROP CONSTRAINT "PurchaseRequestItem_requestId_fkey";

-- DropForeignKey
ALTER TABLE "QualityInspection" DROP CONSTRAINT "QualityInspection_receiptId_fkey";

-- DropForeignKey
ALTER TABLE "Receipt" DROP CONSTRAINT "Receipt_orderId_fkey";

-- DropForeignKey
ALTER TABLE "ReceiptItem" DROP CONSTRAINT "ReceiptItem_receiptId_fkey";

-- DropForeignKey
ALTER TABLE "RequiredPart" DROP CONSTRAINT "RequiredPart_issuedById_fkey";

-- DropForeignKey
ALTER TABLE "RequiredPart" DROP CONSTRAINT "RequiredPart_partId_fkey";

-- DropForeignKey
ALTER TABLE "RequiredPart" DROP CONSTRAINT "RequiredPart_taskId_fkey";

-- DropForeignKey
ALTER TABLE "RequiredTool" DROP CONSTRAINT "RequiredTool_checkedOutById_fkey";

-- DropForeignKey
ALTER TABLE "RequiredTool" DROP CONSTRAINT "RequiredTool_taskId_fkey";

-- DropForeignKey
ALTER TABLE "RequiredTool" DROP CONSTRAINT "RequiredTool_toolId_fkey";

-- DropForeignKey
ALTER TABLE "ResourceAvailability" DROP CONSTRAINT "ResourceAvailability_resourceId_fkey";

-- DropForeignKey
ALTER TABLE "ResourceCertification" DROP CONSTRAINT "ResourceCertification_resourceId_fkey";

-- DropForeignKey
ALTER TABLE "ResourceSkill" DROP CONSTRAINT "ResourceSkill_resourceId_fkey";

-- DropForeignKey
ALTER TABLE "ServiceBulletin" DROP CONSTRAINT "ServiceBulletin_createdById_fkey";

-- DropForeignKey
ALTER TABLE "ServiceBulletin" DROP CONSTRAINT "ServiceBulletin_updatedById_fkey";

-- DropForeignKey
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey";

-- DropForeignKey
ALTER TABLE "StockMovement" DROP CONSTRAINT "StockMovement_itemId_fkey";

-- DropForeignKey
ALTER TABLE "StockMovement" DROP CONSTRAINT "StockMovement_receiptId_fkey";

-- DropForeignKey
ALTER TABLE "StockMovement" DROP CONSTRAINT "StockMovement_workOrderId_fkey";

-- DropForeignKey
ALTER TABLE "Subtask" DROP CONSTRAINT "Subtask_completedById_fkey";

-- DropForeignKey
ALTER TABLE "Subtask" DROP CONSTRAINT "Subtask_taskId_fkey";

-- DropForeignKey
ALTER TABLE "TaskAttachment" DROP CONSTRAINT "TaskAttachment_taskId_fkey";

-- DropForeignKey
ALTER TABLE "TaskAttachment" DROP CONSTRAINT "TaskAttachment_uploadedById_fkey";

-- DropForeignKey
ALTER TABLE "TaskSignoff" DROP CONSTRAINT "TaskSignoff_signedById_fkey";

-- DropForeignKey
ALTER TABLE "TaskSignoff" DROP CONSTRAINT "TaskSignoff_taskId_fkey";

-- DropForeignKey
ALTER TABLE "ToolCheckout" DROP CONSTRAINT "ToolCheckout_toolId_fkey";

-- DropForeignKey
ALTER TABLE "ToolDocument" DROP CONSTRAINT "ToolDocument_toolId_fkey";

-- DropForeignKey
ALTER TABLE "ToolLocationHistory" DROP CONSTRAINT "ToolLocationHistory_toolId_fkey";

-- DropForeignKey
ALTER TABLE "User" DROP CONSTRAINT "User_departmentId_fkey";

-- DropForeignKey
ALTER TABLE "VendorContact" DROP CONSTRAINT "VendorContact_vendorId_fkey";

-- DropForeignKey
ALTER TABLE "VendorDocument" DROP CONSTRAINT "VendorDocument_vendorId_fkey";

-- DropForeignKey
ALTER TABLE "VendorPerformance" DROP CONSTRAINT "VendorPerformance_vendorId_fkey";

-- DropForeignKey
ALTER TABLE "WeightBalanceCalculation" DROP CONSTRAINT "WeightBalanceCalculation_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "WeightBalanceCalculation" DROP CONSTRAINT "WeightBalanceCalculation_configId_fkey";

-- DropForeignKey
ALTER TABLE "WeightBalanceConfig" DROP CONSTRAINT "WeightBalanceConfig_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "WeightBalanceDocument" DROP CONSTRAINT "WeightBalanceDocument_calculationId_fkey";

-- DropForeignKey
ALTER TABLE "WorkOrder" DROP CONSTRAINT "WorkOrder_aircraftId_fkey";

-- DropForeignKey
ALTER TABLE "WorkOrder" DROP CONSTRAINT "WorkOrder_scheduleId_fkey";

-- DropForeignKey
ALTER TABLE "WorkOrderAttachment" DROP CONSTRAINT "WorkOrderAttachment_workOrderId_fkey";

-- DropForeignKey
ALTER TABLE "WorkOrderHistory" DROP CONSTRAINT "WorkOrderHistory_workOrderId_fkey";

-- DropForeignKey
ALTER TABLE "_AircraftToAirworthinessDirective" DROP CONSTRAINT "_AircraftToAirworthinessDirective_A_fkey";

-- DropForeignKey
ALTER TABLE "_AircraftToAirworthinessDirective" DROP CONSTRAINT "_AircraftToAirworthinessDirective_B_fkey";

-- DropForeignKey
ALTER TABLE "_AircraftToKnowledgeArticle" DROP CONSTRAINT "_AircraftToKnowledgeArticle_A_fkey";

-- DropForeignKey
ALTER TABLE "_AircraftToKnowledgeArticle" DROP CONSTRAINT "_AircraftToKnowledgeArticle_B_fkey";

-- DropForeignKey
ALTER TABLE "_AircraftToServiceBulletin" DROP CONSTRAINT "_AircraftToServiceBulletin_A_fkey";

-- DropForeignKey
ALTER TABLE "_AircraftToServiceBulletin" DROP CONSTRAINT "_AircraftToServiceBulletin_B_fkey";

-- DropForeignKey
ALTER TABLE "_AssignedStaff" DROP CONSTRAINT "_AssignedStaff_A_fkey";

-- DropForeignKey
ALTER TABLE "_AssignedStaff" DROP CONSTRAINT "_AssignedStaff_B_fkey";

-- DropForeignKey
ALTER TABLE "_ComponentToKnowledgeArticle" DROP CONSTRAINT "_ComponentToKnowledgeArticle_A_fkey";

-- DropForeignKey
ALTER TABLE "_ComponentToKnowledgeArticle" DROP CONSTRAINT "_ComponentToKnowledgeArticle_B_fkey";

-- DropForeignKey
ALTER TABLE "_KnowledgeArticleToKnowledgeTag" DROP CONSTRAINT "_KnowledgeArticleToKnowledgeTag_A_fkey";

-- DropForeignKey
ALTER TABLE "_KnowledgeArticleToKnowledgeTag" DROP CONSTRAINT "_KnowledgeArticleToKnowledgeTag_B_fkey";

-- DropForeignKey
ALTER TABLE "_StaffWorkOrders" DROP CONSTRAINT "_StaffWorkOrders_A_fkey";

-- DropForeignKey
ALTER TABLE "_StaffWorkOrders" DROP CONSTRAINT "_StaffWorkOrders_B_fkey";

-- AlterTable
ALTER TABLE "Document" DROP COLUMN "version",
DROP COLUMN "type",
ADD COLUMN     "type" "DmsDocumentType" NOT NULL,
DROP COLUMN "status",
ADD COLUMN     "status" "DmsDocumentStatus" NOT NULL DEFAULT 'DRAFT';

-- AlterTable
ALTER TABLE "DocumentPermission" DROP COLUMN "role",
ADD COLUMN     "role" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "DocumentVersion" DROP COLUMN "changes",
DROP COLUMN "version",
ADD COLUMN     "changeDescription" TEXT,
ADD COLUMN     "isCurrent" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN     "versionNumber" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "DocumentWorkflow" ADD COLUMN     "comment" TEXT,
ADD COLUMN     "createdById" TEXT NOT NULL,
ADD COLUMN     "type" TEXT NOT NULL,
ALTER COLUMN "dueDate" SET NOT NULL,
DROP COLUMN "status",
ADD COLUMN     "status" TEXT NOT NULL;

-- DropTable
DROP TABLE "Account";

-- DropTable
DROP TABLE "Aircraft";

-- DropTable
DROP TABLE "AircraftDocument";

-- DropTable
DROP TABLE "AircraftLocation";

-- DropTable
DROP TABLE "AircraftSpecification";

-- DropTable
DROP TABLE "AirworthinessDirective";

-- DropTable
DROP TABLE "Component";

-- DropTable
DROP TABLE "ComponentDocument";

-- DropTable
DROP TABLE "ComponentInstallation";

-- DropTable
DROP TABLE "ComponentMaintenance";

-- DropTable
DROP TABLE "Counter";

-- DropTable
DROP TABLE "CrewLog";

-- DropTable
DROP TABLE "Department";

-- DropTable
DROP TABLE "EngineLog";

-- DropTable
DROP TABLE "FlightDefect";

-- DropTable
DROP TABLE "FlightLog";

-- DropTable
DROP TABLE "InventoryItem";

-- DropTable
DROP TABLE "KnowledgeArticle";

-- DropTable
DROP TABLE "KnowledgeAttachment";

-- DropTable
DROP TABLE "KnowledgeReview";

-- DropTable
DROP TABLE "KnowledgeTag";

-- DropTable
DROP TABLE "LRUHistory";

-- DropTable
DROP TABLE "LRUTracking";

-- DropTable
DROP TABLE "LoadEntry";

-- DropTable
DROP TABLE "LoadStation";

-- DropTable
DROP TABLE "LoadTemplate";

-- DropTable
DROP TABLE "LoadTemplateEntry";

-- DropTable
DROP TABLE "MaintenanceAssignment";

-- DropTable
DROP TABLE "MaintenanceChecklist";

-- DropTable
DROP TABLE "MaintenanceHistory";

-- DropTable
DROP TABLE "MaintenanceLog";

-- DropTable
DROP TABLE "MaintenanceLogPart";

-- DropTable
DROP TABLE "MaintenanceRecord";

-- DropTable
DROP TABLE "MaintenanceResource";

-- DropTable
DROP TABLE "MaintenanceSchedule";

-- DropTable
DROP TABLE "MaintenanceStatus";

-- DropTable
DROP TABLE "MaintenanceTask";

-- DropTable
DROP TABLE "Notification";

-- DropTable
DROP TABLE "PilotLog";

-- DropTable
DROP TABLE "PurchaseOrder";

-- DropTable
DROP TABLE "PurchaseOrderAttachment";

-- DropTable
DROP TABLE "PurchaseOrderItem";

-- DropTable
DROP TABLE "PurchaseRequest";

-- DropTable
DROP TABLE "PurchaseRequestApproval";

-- DropTable
DROP TABLE "PurchaseRequestAttachment";

-- DropTable
DROP TABLE "PurchaseRequestItem";

-- DropTable
DROP TABLE "QualityInspection";

-- DropTable
DROP TABLE "Receipt";

-- DropTable
DROP TABLE "ReceiptItem";

-- DropTable
DROP TABLE "Report";

-- DropTable
DROP TABLE "RequiredPart";

-- DropTable
DROP TABLE "RequiredTool";

-- DropTable
DROP TABLE "ResourceAvailability";

-- DropTable
DROP TABLE "ResourceCertification";

-- DropTable
DROP TABLE "ResourceSkill";

-- DropTable
DROP TABLE "ServiceBulletin";

-- DropTable
DROP TABLE "Session";

-- DropTable
DROP TABLE "Staff";

-- DropTable
DROP TABLE "StockMovement";

-- DropTable
DROP TABLE "Subtask";

-- DropTable
DROP TABLE "TaskAttachment";

-- DropTable
DROP TABLE "TaskSignoff";

-- DropTable
DROP TABLE "Tool";

-- DropTable
DROP TABLE "ToolCheckout";

-- DropTable
DROP TABLE "ToolDocument";

-- DropTable
DROP TABLE "ToolLocationHistory";

-- DropTable
DROP TABLE "User";

-- DropTable
DROP TABLE "Vendor";

-- DropTable
DROP TABLE "VendorContact";

-- DropTable
DROP TABLE "VendorDocument";

-- DropTable
DROP TABLE "VendorPerformance";

-- DropTable
DROP TABLE "VerificationToken";

-- DropTable
DROP TABLE "WeightBalanceCalculation";

-- DropTable
DROP TABLE "WeightBalanceConfig";

-- DropTable
DROP TABLE "WeightBalanceDocument";

-- DropTable
DROP TABLE "WorkOrder";

-- DropTable
DROP TABLE "WorkOrderAttachment";

-- DropTable
DROP TABLE "WorkOrderHistory";

-- DropTable
DROP TABLE "_AircraftToAirworthinessDirective";

-- DropTable
DROP TABLE "_AircraftToKnowledgeArticle";

-- DropTable
DROP TABLE "_AircraftToServiceBulletin";

-- DropTable
DROP TABLE "_AssignedStaff";

-- DropTable
DROP TABLE "_ComponentToKnowledgeArticle";

-- DropTable
DROP TABLE "_KnowledgeArticleToKnowledgeTag";

-- DropTable
DROP TABLE "_StaffWorkOrders";

-- DropEnum
DROP TYPE "ApprovalStatus";

-- DropEnum
DROP TYPE "ArticleStatus";

-- DropEnum
DROP TYPE "AssignmentStatus";

-- DropEnum
DROP TYPE "AvailabilityStatus";

-- DropEnum
DROP TYPE "CertStatus";

-- DropEnum
DROP TYPE "DocumentRole";

-- DropEnum
DROP TYPE "DocumentStatus";

-- DropEnum
DROP TYPE "DocumentType";

-- DropEnum
DROP TYPE "InspectionStatus";

-- DropEnum
DROP TYPE "ItemType";

-- DropEnum
DROP TYPE "KnowledgeType";

-- DropEnum
DROP TYPE "LRUStatus";

-- DropEnum
DROP TYPE "MaintenancePriority";

-- DropEnum
DROP TYPE "MaintenanceType";

-- DropEnum
DROP TYPE "MovementType";

-- DropEnum
DROP TYPE "NotificationStatus";

-- DropEnum
DROP TYPE "NotificationType";

-- DropEnum
DROP TYPE "OrderStatus";

-- DropEnum
DROP TYPE "OrderType";

-- DropEnum
DROP TYPE "Priority";

-- DropEnum
DROP TYPE "ReceiptStatus";

-- DropEnum
DROP TYPE "RequestStatus";

-- DropEnum
DROP TYPE "RequestType";

-- DropEnum
DROP TYPE "ResourceStatus";

-- DropEnum
DROP TYPE "ResourceType";

-- DropEnum
DROP TYPE "Role";

-- DropEnum
DROP TYPE "ScheduleStatus";

-- DropEnum
DROP TYPE "SignoffType";

-- DropEnum
DROP TYPE "SkillCategory";

-- DropEnum
DROP TYPE "SkillLevel";

-- DropEnum
DROP TYPE "StaffStatus";

-- DropEnum
DROP TYPE "Status";

-- DropEnum
DROP TYPE "SubtaskStatus";

-- DropEnum
DROP TYPE "TaskPriority";

-- DropEnum
DROP TYPE "TaskStatus";

-- DropEnum
DROP TYPE "WorkOrderStatus";

-- DropEnum
DROP TYPE "WorkflowStatus";

-- CreateIndex
CREATE INDEX "Document_createdById_idx" ON "Document"("createdById");

-- CreateIndex
CREATE INDEX "Document_type_idx" ON "Document"("type");

-- CreateIndex
CREATE INDEX "Document_status_idx" ON "Document"("status");

-- CreateIndex
CREATE INDEX "Document_department_idx" ON "Document"("department");

-- CreateIndex
CREATE INDEX "DocumentAuditLog_documentId_idx" ON "DocumentAuditLog"("documentId");

-- CreateIndex
CREATE INDEX "DocumentAuditLog_userId_idx" ON "DocumentAuditLog"("userId");

-- CreateIndex
CREATE INDEX "DocumentAuditLog_action_idx" ON "DocumentAuditLog"("action");

-- CreateIndex
CREATE INDEX "DocumentPermission_userId_idx" ON "DocumentPermission"("userId");

-- CreateIndex
CREATE UNIQUE INDEX "DocumentPermission_documentId_userId_key" ON "DocumentPermission"("documentId", "userId");

-- CreateIndex
CREATE INDEX "DocumentVersion_documentId_idx" ON "DocumentVersion"("documentId");

-- CreateIndex
CREATE INDEX "DocumentVersion_createdById_idx" ON "DocumentVersion"("createdById");

-- CreateIndex
CREATE INDEX "DocumentWorkflow_documentId_idx" ON "DocumentWorkflow"("documentId");

-- CreateIndex
CREATE INDEX "DocumentWorkflow_assignedToId_idx" ON "DocumentWorkflow"("assignedToId");

-- CreateIndex
CREATE INDEX "DocumentWorkflow_status_idx" ON "DocumentWorkflow"("status");
