uup
This commit is contained in:
45
prisma/migrations/20250827142342_newdis/migration.sql
Normal file
45
prisma/migrations/20250827142342_newdis/migration.sql
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `maintenanceType` on the `maintenance_visits` table. All the data in the column will be lost.
|
||||
- Added the required column `maintenanceTypeId` to the `maintenance_visits` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- CreateTable
|
||||
CREATE TABLE "maintenance_types" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdDate" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updateDate" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- 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,
|
||||
"maintenanceTypeId" INTEGER 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,
|
||||
CONSTRAINT "maintenance_visits_maintenanceTypeId_fkey" FOREIGN KEY ("maintenanceTypeId") REFERENCES "maintenance_types" ("id") ON DELETE RESTRICT 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;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "maintenance_types_name_key" ON "maintenance_types"("name");
|
||||
Reference in New Issue
Block a user