-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from omsimos/dev
Migrate database to libSQL/Turso
- Loading branch information
Showing
36 changed files
with
631 additions
and
360 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ yarn-error.log* | |
|
||
# turbo | ||
.turbo | ||
.vercel |
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
Binary file not shown.
Binary file not shown.
90 changes: 90 additions & 0 deletions
90
apps/web/prisma/migrations/20240407070104_init/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 @@ | ||
-- CreateTable | ||
CREATE TABLE "Account" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"userId" TEXT NOT NULL, | ||
"type" TEXT NOT NULL, | ||
"provider" TEXT NOT NULL, | ||
"providerAccountId" TEXT NOT NULL, | ||
"refresh_token" TEXT, | ||
"access_token" TEXT, | ||
"expires_at" INTEGER, | ||
"token_type" TEXT, | ||
"scope" TEXT, | ||
"id_token" TEXT, | ||
"session_state" TEXT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"name" TEXT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"email" TEXT, | ||
"emailVerified" DATETIME, | ||
"username" TEXT, | ||
"password" TEXT, | ||
"image" TEXT, | ||
"message" TEXT NOT NULL DEFAULT 'Send me an anonymous message!' | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "VerificationToken" ( | ||
"identifier" TEXT NOT NULL, | ||
"token" TEXT NOT NULL, | ||
"expires" DATETIME NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Message" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"receiverMsg" TEXT NOT NULL, | ||
"isOpened" BOOLEAN NOT NULL DEFAULT false, | ||
"reply" TEXT, | ||
"clue" TEXT, | ||
"senderId" TEXT, | ||
"receiverUsername" TEXT, | ||
"receiverId" TEXT NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "GlobalMessage" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"isAnonymous" BOOLEAN NOT NULL DEFAULT true, | ||
"userId" TEXT | ||
); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Account_userId_idx" ON "Account"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "User_email_username_idx" ON "User"("email", "username"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Message_senderId_createdAt_idx" ON "Message"("senderId", "createdAt" DESC); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Message_receiverId_createdAt_idx" ON "Message"("receiverId", "createdAt" DESC); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "GlobalMessage_userId_updatedAt_idx" ON "GlobalMessage"("userId", "updatedAt" DESC); |
8 changes: 8 additions & 0 deletions
8
apps/web/prisma/migrations/20240408052932_add_global_msg_index/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,8 @@ | ||
-- DropIndex | ||
DROP INDEX "GlobalMessage_userId_updatedAt_idx"; | ||
|
||
-- CreateIndex | ||
CREATE INDEX "GlobalMessage_userId_idx" ON "GlobalMessage"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "GlobalMessage_updatedAt_idx" ON "GlobalMessage"("updatedAt" DESC); |
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "sqlite" |
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,94 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["driverAdapters"] | ||
} | ||
|
||
datasource db { | ||
provider = "sqlite" | ||
url = "file:./dev.db" | ||
relationMode = "prisma" | ||
} | ||
|
||
model Account { | ||
id String @id @default(cuid()) | ||
userId String | ||
type String | ||
provider String | ||
providerAccountId String | ||
refresh_token String? | ||
access_token String? | ||
expires_at Int? | ||
token_type String? | ||
scope String? | ||
id_token String? | ||
session_state String? | ||
user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
@@unique([provider, providerAccountId]) | ||
@@index([userId]) | ||
} | ||
|
||
model User { | ||
id String @id @default(cuid()) | ||
name String? | ||
createdAt DateTime @default(now()) | ||
email String? @unique | ||
emailVerified DateTime? | ||
username String? @unique | ||
password String? | ||
image String? | ||
message String @default("Send me an anonymous message!") | ||
accounts Account[] | ||
sentMessages Message[] @relation("sentMessages") | ||
sentGlobalMessages GlobalMessage[] @relation("sentGlobalMessages") | ||
receivedMessages Message[] @relation("receivedMessages") | ||
@@index([email, username]) | ||
} | ||
|
||
model VerificationToken { | ||
identifier String | ||
token String @unique | ||
expires DateTime | ||
@@unique([identifier, token]) | ||
} | ||
|
||
model Message { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
content String | ||
receiverMsg String | ||
isOpened Boolean @default(false) | ||
reply String? | ||
clue String? | ||
senderId String? | ||
sender User? @relation(name: "sentMessages", fields: [senderId], references: [id]) | ||
receiverUsername String? | ||
receiverId String | ||
receiver User @relation(name: "receivedMessages", fields: [receiverId], references: [id], onDelete: Cascade) | ||
@@index([senderId, createdAt(sort: Desc)]) | ||
@@index([receiverId, createdAt(sort: Desc)]) | ||
} | ||
|
||
model GlobalMessage { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
content String | ||
isAnonymous Boolean @default(true) | ||
userId String? | ||
user User? @relation(name: "sentGlobalMessages", fields: [userId], references: [id], onDelete: Cascade) | ||
@@index([userId]) | ||
@@index([updatedAt(sort: Desc)]) | ||
} |
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
Oops, something went wrong.