explit/prisma/migrations/20220213201936_add_teamid/migration.sql

24 lines
902 B
MySQL
Raw Normal View History

2022-02-13 21:25:00 +01:00
/*
Warnings:
- Added the required column `teamId` to the `Expense` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Expense" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"teamId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"description" TEXT NOT NULL,
"amount" REAL NOT NULL,
CONSTRAINT "Expense_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Expense" ("amount", "createdAt", "description", "id", "updatedAt", "userId") SELECT "amount", "createdAt", "description", "id", "updatedAt", "userId" FROM "Expense";
DROP TABLE "Expense";
ALTER TABLE "new_Expense" RENAME TO "Expense";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;