Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate db to planetscale #16

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions prisma/migrations/20230721210247_100_cims/migration.sql

This file was deleted.

69 changes: 0 additions & 69 deletions prisma/migrations/20230721234541_add_cims/migration.sql

This file was deleted.

3 changes: 0 additions & 3 deletions prisma/migrations/migration_lock.toml

This file was deleted.

90 changes: 53 additions & 37 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
directUrl = env("POSTGRES_URL_NON_POOLING")
generator client {
provider = "prisma-client-js"
}

generator client {
provider = "prisma-client-js"
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
// url = env("DATABASE_SHADOW_URL")
relationMode = "prisma"
}

model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?

user User @relation(fields: [userId], references: [id], onDelete: Cascade)
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([provider, providerAccountId])
@@index([userId])
}

model Session {
Expand All @@ -34,17 +34,19 @@ model Session {
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@index([userId])
}

model User {
id String @id @default(cuid())
id String @id @default(cuid())
name String?
email String? @unique
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
cims Cim[]
cims CimToUser[]
}

model VerificationToken {
Expand All @@ -56,20 +58,34 @@ model VerificationToken {
}

model Cim {
id String @id @default(cuid())
name String @unique
altitude Int
longitude Float
latitude Float
url String @unique
img String? @unique
essencial Boolean
comarcas Comarca[]
users User[]
id String @id @default(cuid())
name String @unique
altitude Int
longitude Float
latitude Float
url String @unique
img String? @unique
essencial Boolean
comarcas Comarca[]
users CimToUser[]
}

model Comarca {
id String @id @default(cuid())
name String @unique
cims Cim[]
id String @id @default(cuid())
name String @unique
cims Cim[]
}

model CimToUser {
cim Cim @relation(fields: [cimId], references: [id])
cimId String
user User @relation(fields: [userId], references: [id])
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

@@unique([cimId, userId])
@@id([cimId, userId])
@@index([userId])
@@index([cimId])
}
Loading
Loading