|
| 1 | +-- RedefineTables |
| 2 | +PRAGMA defer_foreign_keys=ON; |
| 3 | +PRAGMA foreign_keys=OFF; |
| 4 | +CREATE TABLE "new_legs" ( |
| 5 | + "id" TEXT NOT NULL PRIMARY KEY, |
| 6 | + "dayId" INTEGER, |
| 7 | + "route" TEXT, |
| 8 | + "useBlock" BOOLEAN NOT NULL, |
| 9 | + "positionsFromTracker" BOOLEAN NOT NULL DEFAULT false, |
| 10 | + "ident" TEXT, |
| 11 | + "originAirportId" TEXT, |
| 12 | + "destinationAirportId" TEXT, |
| 13 | + "diversionAirportId" TEXT, |
| 14 | + "startTime_utc" INTEGER NOT NULL, |
| 15 | + "endTime_utc" INTEGER NOT NULL, |
| 16 | + "relativeOrder" INTEGER NOT NULL DEFAULT 0, |
| 17 | + "totalTime" REAL NOT NULL DEFAULT 0, |
| 18 | + "pic" REAL NOT NULL DEFAULT 0, |
| 19 | + "sic" REAL NOT NULL DEFAULT 0, |
| 20 | + "night" REAL NOT NULL DEFAULT 0, |
| 21 | + "solo" REAL NOT NULL DEFAULT 0, |
| 22 | + "xc" REAL NOT NULL DEFAULT 0, |
| 23 | + "distance" REAL NOT NULL DEFAULT 0, |
| 24 | + "dayTakeOffs" INTEGER NOT NULL DEFAULT 0, |
| 25 | + "dayLandings" INTEGER NOT NULL DEFAULT 0, |
| 26 | + "nightTakeOffs" INTEGER NOT NULL DEFAULT 0, |
| 27 | + "nightLandings" INTEGER NOT NULL DEFAULT 0, |
| 28 | + "simulatedInstrument" REAL NOT NULL DEFAULT 0, |
| 29 | + "actualInstrument" REAL NOT NULL DEFAULT 0, |
| 30 | + "holds" INTEGER NOT NULL DEFAULT 0, |
| 31 | + "dualGiven" REAL NOT NULL DEFAULT 0, |
| 32 | + "dualReceived" REAL NOT NULL DEFAULT 0, |
| 33 | + "crossing" BOOLEAN NOT NULL DEFAULT false, |
| 34 | + "flightReview" BOOLEAN NOT NULL DEFAULT false, |
| 35 | + "checkride" BOOLEAN NOT NULL DEFAULT false, |
| 36 | + "ipc" BOOLEAN NOT NULL DEFAULT false, |
| 37 | + "faa6158" BOOLEAN NOT NULL DEFAULT false, |
| 38 | + "lineCheck" BOOLEAN NOT NULL DEFAULT false, |
| 39 | + "passengers" INTEGER NOT NULL DEFAULT 0, |
| 40 | + "notes" TEXT NOT NULL DEFAULT '', |
| 41 | + "aircraftId" TEXT NOT NULL, |
| 42 | + CONSTRAINT "legs_dayId_fkey" FOREIGN KEY ("dayId") REFERENCES "days" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, |
| 43 | + CONSTRAINT "legs_originAirportId_fkey" FOREIGN KEY ("originAirportId") REFERENCES "airports" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, |
| 44 | + CONSTRAINT "legs_destinationAirportId_fkey" FOREIGN KEY ("destinationAirportId") REFERENCES "airports" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, |
| 45 | + CONSTRAINT "legs_diversionAirportId_fkey" FOREIGN KEY ("diversionAirportId") REFERENCES "airports" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, |
| 46 | + CONSTRAINT "legs_aircraftId_fkey" FOREIGN KEY ("aircraftId") REFERENCES "aircraft" ("id") ON DELETE RESTRICT ON UPDATE CASCADE |
| 47 | +); |
| 48 | +INSERT INTO "new_legs" ("actualInstrument", "aircraftId", "checkride", "crossing", "dayId", "dayLandings", "dayTakeOffs", "destinationAirportId", "distance", "diversionAirportId", "dualGiven", "dualReceived", "endTime_utc", "faa6158", "flightReview", "holds", "id", "ident", "ipc", "night", "nightLandings", "nightTakeOffs", "notes", "originAirportId", "passengers", "pic", "positionsFromTracker", "relativeOrder", "route", "sic", "simulatedInstrument", "solo", "startTime_utc", "totalTime", "useBlock", "xc") SELECT "actualInstrument", "aircraftId", "checkride", "crossing", "dayId", "dayLandings", "dayTakeOffs", "destinationAirportId", "distance", "diversionAirportId", "dualGiven", "dualReceived", "endTime_utc", "faa6158", "flightReview", "holds", "id", "ident", "ipc", "night", "nightLandings", "nightTakeOffs", "notes", "originAirportId", "passengers", "pic", "positionsFromTracker", "relativeOrder", "route", "sic", "simulatedInstrument", "solo", "startTime_utc", "totalTime", "useBlock", "xc" FROM "legs"; |
| 49 | +DROP TABLE "legs"; |
| 50 | +ALTER TABLE "new_legs" RENAME TO "legs"; |
| 51 | +ALTER TABLE "tours" RENAME COLUMN "lineCheck" TO "trainingEvent"; |
| 52 | + |
| 53 | +PRAGMA foreign_keys=ON; |
| 54 | +PRAGMA defer_foreign_keys=OFF; |
0 commit comments