mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* Revert "revert: UserPassword (#13680)"
This reverts commit 0a68c6d048.
* fix: avoid updates for possible missing passwords
32 lines
752 B
SQL
32 lines
752 B
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the column `password` on the `users` table. All the data in the column will be lost.
|
|
|
|
*/
|
|
-- CreateTable
|
|
CREATE TABLE
|
|
"UserPassword" (
|
|
"hash" TEXT NOT NULL,
|
|
"userId" INTEGER NOT NULL
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "UserPassword_userId_key" ON "UserPassword" ("userId");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "UserPassword" ADD CONSTRAINT "UserPassword_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- Inserts current user password into new table
|
|
INSERT INTO
|
|
"UserPassword" ("hash", "userId")
|
|
SELECT
|
|
u."password",
|
|
u.id
|
|
FROM
|
|
users u
|
|
WHERE
|
|
u."password" IS NOT NULL;
|
|
|
|
-- TODO for next migration.
|
|
-- ALTER TABLE "users" DROP COLUMN "password"; |