car_mms/prisma/migrations/20250827220800_newdis2/migration.sql
2025-09-11 14:22:27 +03:00

32 lines
1.7 KiB
SQL

/*
Warnings:
- You are about to drop the column `maintenanceTypeId` on the `maintenance_visits` table. All the data in the column will be lost.
- Added the required column `maintenanceJobs` to the `maintenance_visits` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_maintenance_visits" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"vehicleId" INTEGER NOT NULL,
"customerId" INTEGER NOT NULL,
"maintenanceJobs" TEXT NOT NULL,
"description" TEXT NOT NULL,
"cost" REAL NOT NULL,
"paymentStatus" TEXT NOT NULL DEFAULT 'pending',
"kilometers" INTEGER NOT NULL,
"visitDate" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"nextVisitDelay" INTEGER NOT NULL,
"createdDate" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updateDate" DATETIME NOT NULL,
CONSTRAINT "maintenance_visits_vehicleId_fkey" FOREIGN KEY ("vehicleId") REFERENCES "vehicles" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "maintenance_visits_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customers" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_maintenance_visits" ("cost", "createdDate", "customerId", "description", "id", "kilometers", "nextVisitDelay", "paymentStatus", "updateDate", "vehicleId", "visitDate") SELECT "cost", "createdDate", "customerId", "description", "id", "kilometers", "nextVisitDelay", "paymentStatus", "updateDate", "vehicleId", "visitDate" FROM "maintenance_visits";
DROP TABLE "maintenance_visits";
ALTER TABLE "new_maintenance_visits" RENAME TO "maintenance_visits";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;