v28
v28
Explore posts from servers
PPrisma
Created by v28 on 5/7/2025 in #help-and-questions
renaming column names
Hello, In the past I've made some really bad naming decisions for my columns and I'm wanting to rename these now. current schema:
model CustomInstance {
id Int @id @default(autoincrement())
botStatusType BotStatusTypes
botStatusText String
}
model CustomInstance {
id Int @id @default(autoincrement())
botStatusType BotStatusTypes
botStatusText String
}
I would like to rename the botStatusType column to botActivityType. To do this I tried using the @map property, below is an example of how i tried this:
model CustomInstance {
id Int @id @default(autoincrement())
botStatusType BotStatusTypes @map(name: "botActivityType")
botStatusText String @map(name: "botActivityText")
}
model CustomInstance {
id Int @id @default(autoincrement())
botStatusType BotStatusTypes @map(name: "botActivityType")
botStatusText String @map(name: "botActivityText")
}
My database is populated full of data which cannot be removed, id like this schema change to be seemless, but when attempting to prisma db push I get the following error:
⚠️ We found changes that cannot be executed:
• Added the required column `botActivityText` to the `CustomInstance` table without a default value. There are 1 rows in this table, it is not possible to execute this step.
• Added the required column `botActivityType` to the `CustomInstance` table without a default value. There are 1 rows in this table, it is not possible to execute this step.
⚠️ We found changes that cannot be executed:
• Added the required column `botActivityText` to the `CustomInstance` table without a default value. There are 1 rows in this table, it is not possible to execute this step.
• Added the required column `botActivityType` to the `CustomInstance` table without a default value. There are 1 rows in this table, it is not possible to execute this step.
2 replies
TtRPC
Created by v28 on 10/31/2024 in #❓-help
Correct way to fetch trpc data on SSR and CSR
Hello, I am currently using trpc in my nextjs app router project and I am wondering what the best way of using trpc is with a mixture of SSR and CSR. The issue I'm having is that because I'm fetching the data on the server, it also fetches on the client which menas I'm making a request needlessly, and I'm not sure what the best way of dealing with this is. I have a page which is SSR rendered, so I fetch the data which will be used by the page:
"use server"

export default async function Applications({ params }: Props) {
const { guildId } = await params;
const applications = await api.application.getAll({ guildId });

return (
<HydrateClient>
<h1>Applications {guildId}</h1>
<Test applications={applications} />
</HydrateClient>
);
}
"use server"

export default async function Applications({ params }: Props) {
const { guildId } = await params;
const applications = await api.application.getAll({ guildId });

return (
<HydrateClient>
<h1>Applications {guildId}</h1>
<Test applications={applications} />
</HydrateClient>
);
}
"use client"

export const Test = ({ applications, guildId }: TestProps) => {
const { data, refetch } = api.application.getAll.useQuery(
{
guildId: guildId,
}
);
const [apps, setApps] = useState(applications);

useEffect(() => {
if (data) {
setApps(data);
}
}, [data, applications]);

return (
<div>
<h1>Test</h1>
{apps.map((application) => (
<div key={application.id}>{application.name}</div>
))}
<Button
onClick={async () => {
await refetch();
}}
>
refetch
</Button>
</div>
);
};
"use client"

export const Test = ({ applications, guildId }: TestProps) => {
const { data, refetch } = api.application.getAll.useQuery(
{
guildId: guildId,
}
);
const [apps, setApps] = useState(applications);

useEffect(() => {
if (data) {
setApps(data);
}
}, [data, applications]);

return (
<div>
<h1>Test</h1>
{apps.map((application) => (
<div key={application.id}>{application.name}</div>
))}
<Button
onClick={async () => {
await refetch();
}}
>
refetch
</Button>
</div>
);
};
1 replies