diff --git a/.vscode/settings.json b/.vscode/settings.json index f700007..f8a5085 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,7 @@ "autodocs", "Bebas", "cruseo", - "Neue" + "Neue", + "supabase" ] } diff --git a/api/db/schema.prisma b/api/db/schema.prisma index 628001a..9c8c1e5 100644 --- a/api/db/schema.prisma +++ b/api/db/schema.prisma @@ -1,15 +1,15 @@ +generator client { + provider = "prisma-client-js" + previewFeatures = ["multiSchema"] + binaryTargets = ["native"] +} + datasource db { provider = "postgresql" url = env("DATABASE_URL") + schemas = ["auth", "public"] } -generator client { - provider = "prisma-client-js" - binaryTargets = "native" -} - -// Define your own datamodels here and run `yarn redwood prisma migrate dev` -// to create migrations for them and apply to your dev DB. model User { id Int @id @default(autoincrement()) email String @unique @@ -19,32 +19,25 @@ model User { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt role Role @default(USER) + person Pairings[] @relation("Pairings_Person") + santa Pairings[] @relation("Pairings_Santa") + thankYouToUser ThankYou[] @relation("ThankYou_ToUser") + thankYouAuthor ThankYou[] @relation("ThankYou_User") status UserStatus[] - santa Pairings[] @relation(name: "Pairings_Santa") - person Pairings[] @relation(name: "Pairings_Person") wishList WishList[] - thankYouAuthor ThankYou[] @relation(name: "ThankYou_User") - thankYouToUser ThankYou[] @relation(name: "ThankYou_ToUser") -} -enum Role { - USER - ADMIN + @@schema("public") } model UserStatus { id Int @id @default(autoincrement()) userId Int - user User @relation(fields: [userId], references: [id]) eventId String - event Event @relation(fields: [eventId], references: [id]) status InvitationStatus -} + event Event @relation(fields: [eventId], references: [id]) + user User @relation(fields: [userId], references: [id]) -enum InvitationStatus { - INVITED - DECLINED - ACCEPTED + @@schema("public") } model Event { @@ -54,22 +47,26 @@ model Event { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt sendReminder Boolean @default(false) - userStatus UserStatus[] pairings Pairings[] - wishList WishList[] thankYou ThankYou[] + userStatus UserStatus[] + wishList WishList[] + + @@schema("public") } model Pairings { id Int @id @default(autoincrement()) eventId String - event Event @relation(fields: [eventId], references: [id]) santaId Int - santa User @relation(fields: [santaId], references: [id], name: "Pairings_Santa") personId Int - person User @relation(fields: [personId], references: [id], name: "Pairings_Person") createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + event Event @relation(fields: [eventId], references: [id]) + person User @relation("Pairings_Person", fields: [personId], references: [id]) + santa User @relation("Pairings_Santa", fields: [santaId], references: [id]) + + @@schema("public") } model WishList { @@ -77,25 +74,353 @@ model WishList { name String url String userId Int - user User @relation(fields: [userId], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt order Int? eventId String - event Event @relation(fields: [eventId], references: [id]) siteImage String? siteTitle String? siteDescription String? + event Event @relation(fields: [eventId], references: [id]) + user User @relation(fields: [userId], references: [id]) + + @@schema("public") } model ThankYou { id Int @id @default(autoincrement()) eventId String - event Event @relation(fields: [eventId], references: [id]) userId Int - user User @relation(fields: [userId], references: [id], name: "ThankYou_User") toUserId Int - toUser User @relation(fields: [toUserId], references: [id], name: "ThankYou_ToUser") message String createdAt DateTime @default(now()) + event Event @relation(fields: [eventId], references: [id]) + toUser User @relation("ThankYou_ToUser", fields: [toUserId], references: [id]) + user User @relation("ThankYou_User", fields: [userId], references: [id]) + + @@schema("public") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model audit_log_entries { + instance_id String? @db.Uuid + id String @id @db.Uuid + payload Json? @db.Json + created_at DateTime? @db.Timestamptz(6) + ip_address String @default("") @db.VarChar(64) + + @@index([instance_id], map: "audit_logs_instance_id_idx") + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model flow_state { + id String @id @db.Uuid + user_id String? @db.Uuid + auth_code String + code_challenge_method code_challenge_method + code_challenge String + provider_type String + provider_access_token String? + provider_refresh_token String? + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + authentication_method String + saml_relay_states saml_relay_states[] + + @@index([created_at(sort: Desc)]) + @@index([auth_code], map: "idx_auth_code") + @@index([user_id, authentication_method], map: "idx_user_id_auth_method") + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model identities { + id String + user_id String @db.Uuid + identity_data Json + provider String + last_sign_in_at DateTime? @db.Timestamptz(6) + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + email String? @default(dbgenerated("lower((identity_data ->> 'email'::text))")) + users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@id([provider, id]) + @@index([email]) + @@index([user_id]) + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model instances { + id String @id @db.Uuid + uuid String? @db.Uuid + raw_base_config String? + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model mfa_amr_claims { + session_id String @db.Uuid + created_at DateTime @db.Timestamptz(6) + updated_at DateTime @db.Timestamptz(6) + authentication_method String + id String @id(map: "amr_id_pk") @db.Uuid + sessions sessions @relation(fields: [session_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@unique([session_id, authentication_method], map: "mfa_amr_claims_session_id_authentication_method_pkey") + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model mfa_challenges { + id String @id @db.Uuid + factor_id String @db.Uuid + created_at DateTime @db.Timestamptz(6) + verified_at DateTime? @db.Timestamptz(6) + ip_address String @db.Inet + mfa_factors mfa_factors @relation(fields: [factor_id], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "mfa_challenges_auth_factor_id_fkey") + + @@index([created_at(sort: Desc)], map: "mfa_challenge_created_at_idx") + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model mfa_factors { + id String @id @db.Uuid + user_id String @db.Uuid + friendly_name String? + factor_type factor_type + status factor_status + created_at DateTime @db.Timestamptz(6) + updated_at DateTime @db.Timestamptz(6) + secret String? + mfa_challenges mfa_challenges[] + users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@index([user_id, created_at], map: "factor_id_created_at_idx") + @@index([user_id]) + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model refresh_tokens { + instance_id String? @db.Uuid + id BigInt @id @default(autoincrement()) + token String? @unique(map: "refresh_tokens_token_unique") @db.VarChar(255) + user_id String? @db.VarChar(255) + revoked Boolean? + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + parent String? @db.VarChar(255) + session_id String? @db.Uuid + sessions sessions? @relation(fields: [session_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@index([instance_id]) + @@index([instance_id, user_id]) + @@index([parent]) + @@index([session_id, revoked]) + @@index([updated_at(sort: Desc)]) + @@schema("auth") +} + +/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info. +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model saml_providers { + id String @id @db.Uuid + sso_provider_id String @db.Uuid + entity_id String @unique + metadata_xml String + metadata_url String? + attribute_mapping Json? + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + sso_providers sso_providers @relation(fields: [sso_provider_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@index([sso_provider_id]) + @@schema("auth") +} + +/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info. +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model saml_relay_states { + id String @id @db.Uuid + sso_provider_id String @db.Uuid + request_id String + for_email String? + redirect_to String? + from_ip_address String? @db.Inet + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + flow_state_id String? @db.Uuid + flow_state flow_state? @relation(fields: [flow_state_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + sso_providers sso_providers @relation(fields: [sso_provider_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@index([created_at(sort: Desc)]) + @@index([for_email]) + @@index([sso_provider_id]) + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model schema_migrations { + version String @id @db.VarChar(255) + + @@schema("auth") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model sessions { + id String @id @db.Uuid + user_id String @db.Uuid + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + factor_id String? @db.Uuid + aal aal_level? + not_after DateTime? @db.Timestamptz(6) + refreshed_at DateTime? @db.Timestamp(6) + user_agent String? + ip String? @db.Inet + mfa_amr_claims mfa_amr_claims[] + refresh_tokens refresh_tokens[] + users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@index([not_after(sort: Desc)]) + @@index([user_id]) + @@index([user_id, created_at], map: "user_id_created_at_idx") + @@schema("auth") +} + +/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info. +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +/// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info. +model sso_domains { + id String @id @db.Uuid + sso_provider_id String @db.Uuid + domain String + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + sso_providers sso_providers @relation(fields: [sso_provider_id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@index([sso_provider_id]) + @@schema("auth") +} + +/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info. +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +/// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info. +model sso_providers { + id String @id @db.Uuid + resource_id String? + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + saml_providers saml_providers[] + saml_relay_states saml_relay_states[] + sso_domains sso_domains[] + + @@schema("auth") +} + +/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info. +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +/// This model contains an expression index which requires additional setup for migrations. Visit https://pris.ly/d/expression-indexes for more info. +model users { + instance_id String? @db.Uuid + id String @id @db.Uuid + aud String? @db.VarChar(255) + role String? @db.VarChar(255) + email String? @db.VarChar(255) + encrypted_password String? @db.VarChar(255) + email_confirmed_at DateTime? @db.Timestamptz(6) + invited_at DateTime? @db.Timestamptz(6) + confirmation_token String? @db.VarChar(255) + confirmation_sent_at DateTime? @db.Timestamptz(6) + recovery_token String? @db.VarChar(255) + recovery_sent_at DateTime? @db.Timestamptz(6) + email_change_token_new String? @db.VarChar(255) + email_change String? @db.VarChar(255) + email_change_sent_at DateTime? @db.Timestamptz(6) + last_sign_in_at DateTime? @db.Timestamptz(6) + raw_app_meta_data Json? + raw_user_meta_data Json? + is_super_admin Boolean? + created_at DateTime? @db.Timestamptz(6) + updated_at DateTime? @db.Timestamptz(6) + phone String? @unique + phone_confirmed_at DateTime? @db.Timestamptz(6) + phone_change String? @default("") + phone_change_token String? @default("") @db.VarChar(255) + phone_change_sent_at DateTime? @db.Timestamptz(6) + confirmed_at DateTime? @default(dbgenerated("LEAST(email_confirmed_at, phone_confirmed_at)")) @db.Timestamptz(6) + email_change_token_current String? @default("") @db.VarChar(255) + email_change_confirm_status Int? @default(0) @db.SmallInt + banned_until DateTime? @db.Timestamptz(6) + reauthentication_token String? @default("") @db.VarChar(255) + reauthentication_sent_at DateTime? @db.Timestamptz(6) + is_sso_user Boolean @default(false) + deleted_at DateTime? @db.Timestamptz(6) + identities identities[] + mfa_factors mfa_factors[] + sessions sessions[] + profiles profiles? + + @@index([instance_id]) + @@schema("auth") +} + +/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info. +model profiles { + id String @id @db.Uuid + name String? + users users @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: NoAction) + + @@schema("public") +} + +enum Role { + USER + ADMIN + + @@schema("public") +} + +enum InvitationStatus { + INVITED + DECLINED + ACCEPTED + + @@schema("public") +} + +enum aal_level { + aal1 + aal2 + aal3 + + @@schema("auth") +} + +enum code_challenge_method { + s256 + plain + + @@schema("auth") +} + +enum factor_status { + unverified + verified + + @@schema("auth") +} + +enum factor_type { + totp + webauthn + + @@schema("auth") }