-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: renomeando tabelas e colunas
- Loading branch information
Showing
4 changed files
with
117 additions
and
27 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
prisma/migrations/20240430104124_change_tables_names/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `Account` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `SocialMedia` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `Token` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Account" DROP CONSTRAINT "Account_socialMediaId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Token" DROP CONSTRAINT "Token_accountId_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "Account"; | ||
|
||
-- DropTable | ||
DROP TABLE "SocialMedia"; | ||
|
||
-- DropTable | ||
DROP TABLE "Token"; | ||
|
||
-- DropTable | ||
DROP TABLE "User"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "users" ( | ||
"id" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"name" TEXT, | ||
"password" TEXT NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"deleted_at" TIMESTAMP(3), | ||
|
||
CONSTRAINT "users_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "accounts" ( | ||
"id" TEXT NOT NULL, | ||
"avatar_url" TEXT NOT NULL, | ||
"user_id" TEXT, | ||
"social_media_id" INTEGER, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "accounts_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "tokens" ( | ||
"id" SERIAL NOT NULL, | ||
"auth_token" TEXT NOT NULL, | ||
"token" TEXT NOT NULL, | ||
"issued_at" TIMESTAMP(3) NOT NULL, | ||
"expire_in" INTEGER NOT NULL, | ||
"account_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "tokens_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "social_media" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"description" TEXT NOT NULL, | ||
|
||
CONSTRAINT "social_media_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "tokens_account_id_key" ON "tokens"("account_id"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_social_media_id_fkey" FOREIGN KEY ("social_media_id") REFERENCES "social_media"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "tokens" ADD CONSTRAINT "tokens_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/features/user/repositories/user-repository/user-repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters