OrBlatt
WWasp-lang
•Created by OrBlatt on 7/6/2024 in #🙋questions
Migrate db in Production fly.io
Given that I have a wasp app I deployed to fly.io, what are the steps I need to do to make sure changes to entity schemas are reflected in Production database?
Additional questions:
1. Has anyone deployed db changes to an already deployed app and can share common pitfalls?
2. Is there a wasp db migrate-dev equivalent such as wasp db migrate-prod?
7 replies
WWasp-lang
•Created by OrBlatt on 7/4/2024 in #🙋questions
db seed verified email
I migrated from username auth to email. the email auth requires email verification. Now, when i seed the database, the Users that I created have unverified emails. How can I verify the emails of the records i see in the database during db seed?
5 replies
WWasp-lang
•Created by OrBlatt on 7/2/2024 in #🙋questions
Derive username from userId
How can i derive the username using a user id?
I have these entities:
entity JobAd {=psl
id Int @id @default(autoincrement())
description String
owner User @relation(name: "createdBy", fields: [ownerId], references: [id])
ownerId Int
provider User? @relation(name: "servedBy", fields: [providerId], references: [id])
providerId Int?
psl=} entity User {=psl id Int @id @default(autoincrement()) isProvider Boolean @default(false) psl=} In my client side, i have a tsx file with the following signature: const SearchResult = ({ jobAd } : { jobAd: JobAd }) => { const { description, ownerId, providerId } = jobAd; How can i get the email address that was used for this user? something like: const username = getUsername(ownerId)
psl=} entity User {=psl id Int @id @default(autoincrement()) isProvider Boolean @default(false) psl=} In my client side, i have a tsx file with the following signature: const SearchResult = ({ jobAd } : { jobAd: JobAd }) => { const { description, ownerId, providerId } = jobAd; How can i get the email address that was used for this user? something like: const username = getUsername(ownerId)
21 replies
WWasp-lang
•Created by OrBlatt on 6/21/2024 in #🙋questions
Scheduling email sending with Pg-boss
Project Overview
I have developed a feature that allows sending a list of tasks via email to the logged-in user using Mailgun. I now want to enhance this functionality by implementing a subscription service for users to receive a digest of new tasks based on a search profile.
Key Requirements
1. Subscription Feature:
- Users can subscribe to a search profile.
- Each search profile will have criteria such as
minPrice
and maxPrice
to filter tasks.
2. Email Digest:
- A digest of new tasks meeting the search profile criteria will be sent via email.
- Users can choose the frequency of the email: daily or weekly.
3. Scheduling with pg-boss:
- Use pg-boss
for scheduling the email dispatch.
- The scheduling should support both daily (cron string: 0 0 * * *
) and weekly (cron string: 0 0 * * 5
) options based on user preference.
Assistance Needed
I need assistance with the following:
1. Implementation of the Subscription Logic:
- How to allow users to create and manage their search profiles.
- Storing user preferences for email frequency.
2. Integration with pg-boss:
- Setting up pg-boss to handle the scheduling based on user preferences.
- Ensuring the correct cron string is used for each user’s chosen frequency.
3. Email Sending:
- Filtering tasks based on the search profile criteria (minPrice
and maxPrice
).
- Formatting the tasks into a digest and sending the email using Mailgun.
Request
Kapa.ai Could you provide a detailed implementation plan or example code snippets to achieve this?20 replies
WWasp-lang
•Created by OrBlatt on 6/13/2024 in #🙋questions
User `postgresWaspDevUser` was denied access on the database
I try to use PostgreSQL database with docker.
i have a terminal process in which i ran the command wasp start db.
In another terminal, I started wasp with wasp start, but I get the following outputs:
Terminal 1:
wasp start db
2024-06-13 22:43:01.339 UTC [1] LOG: database system is ready to accept connections
2024-06-13 22:43:41.772 UTC [33] FATAL: no pg_hba.conf entry for host "192.168.65.1", user "postgresWaspDevUser", database "ServiceConnect-5c2be627cd", no encryption
2024-06-13 22:43:44.538 UTC [34] FATAL: no pg_hba.conf entry for host "192.168.65.1", user "postgresWaspDevUser", database "ServiceConnect-5c2be627cd", no encryption
Terminal 2:
🐝 --- Setting up database... -----------------------------------------------------
[ Db !] Error: P1010
[ Db !]
[ Db !] User
postgresWaspDevUser
was denied access on the database ServiceConnect-5c2be627cd.public
[ Db !]
[ Db ] Environment variables loaded from .env
[ Db ] Prisma schema loaded from ../db/schema.prisma
[ Db ]
[ Db ] ✔ Generated Prisma Client (4.16.2 | library) to ./../../../node_modules/@prisma/client in 44ms
[ Db ] You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
[ Db ]
[ Db ] import { PrismaClient } from '@prisma/client'
[ Db ] const prisma = new PrismaClient()
[ Db ]
How can I fix it?10 replies
WWasp-lang
•Created by OrBlatt on 6/4/2024 in #🙋questions
missing an opposite relation field
In a marketplace app, I have a JobAd entity that is created by an owner of type User. At some point in time after posting the JobAd, another User locks herself as the provider for this JobAd.
I believe the entity definition should be
entity JobAd {=psl
id Int @id @default(autoincrement())
description String
price Float
isDone Boolean @default(false)
createdAt DateTime @default(now())
owner User @relation(name: "createdBy", fields: [ownerId], references: [id])
ownerId Int
provider User? @relation(name: "servedBy", fields: [providerId], references: [id])
providerId Int?
psl=} entity User {=psl id Int @id @default(autoincrement()) isProvider Boolean @default(false) jobAds JobAd[] psl=} However, when I run wasp db migrate-dev, I get the following error P1012 Error validating field
psl=} entity User {=psl id Int @id @default(autoincrement()) isProvider Boolean @default(false) jobAds JobAd[] psl=} However, when I run wasp db migrate-dev, I get the following error P1012 Error validating field
jobAds
in model User
: The relation field jobAds
on model User
is missing an opposite relation field on the model JobAd
. Either run prisma format
or add it manually.
Error validating field owner
in model JobAd
: The relation field owner
on model JobAd
is missing an opposite relation field on the model User
. Either run prisma format
or add it manually.
Error validating field provider
in model JobAd
: The relation field provider
on model JobAd
is missing an opposite relation field on the model User
. Either run prisma format
or add it manually.
How can I fix it?6 replies
WWasp-lang
•Created by OrBlatt on 6/4/2024 in #🙋questions
Timestamp with time zone attribute in PostgreSQL Database
Given I use a postgres database and I want to add a "timestamp with time zone" attribute to a given WASP entity, what's the correct syntax?
entity JobAd {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
user User? @relation(fields: [userId], references: [id])
userId Int?
creationTimestamp Timestamp with time zone @default(now())
psl=}
6 replies