stiba
stiba
Explore posts from servers
DTDrizzle Team
Created by stiba on 6/26/2024 in #help
Migrations complain about missing relations
I get the following error when running migrations:
PostgresError: relation "public.users" does not exist
PostgresError: relation "public.users" does not exist
The weird thing is that the table gets created in the drizzle schema, so when the migration.sql file references "public.users" it fails. The public schema is also only mentioned once in the migration file.
DO $$ BEGIN
CREATE TYPE "public"."account_type" AS ENUM('discord');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "accounts" (
"account_id" text PRIMARY KEY NOT NULL,
"account_type" "account_type" NOT NULL,
"access_token" text NOT NULL,
"refresh_token" text NOT NULL,
"user_id" integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "session" (
"id" text PRIMARY KEY NOT NULL,
"data" json NOT NULL,
"expires_at" timestamp NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar(256),
"email" varchar(256) NOT NULL,
"avatar_url" text
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "email_idx" ON "users" USING btree ("email");
DO $$ BEGIN
CREATE TYPE "public"."account_type" AS ENUM('discord');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "accounts" (
"account_id" text PRIMARY KEY NOT NULL,
"account_type" "account_type" NOT NULL,
"access_token" text NOT NULL,
"refresh_token" text NOT NULL,
"user_id" integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "session" (
"id" text PRIMARY KEY NOT NULL,
"data" json NOT NULL,
"expires_at" timestamp NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar(256),
"email" varchar(256) NOT NULL,
"avatar_url" text
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "email_idx" ON "users" USING btree ("email");
If I remove the "public". infront of "users" the migration runs fine, but every table is created in the drizzle schema. Am I doing something wrong here?
2 replies
SSolidJS
Created by stiba on 11/27/2023 in #support
Infinite scrolling solid-start
I'm trying to create something like an infinite scroll. The data I'm fetching requires api-keys etc, so it has to be done server side. The initial data fetches fine, since it's being fetched on the server, but when I try to fetch more, it tries to call my api class from the browser, and the api-key are undefined (naturally). How can I make my fetchMore function only run on the server? Do I need to create an api route ?
4 replies
SSolidJS
Created by stiba on 10/8/2023 in #support
Route not updating its routeData
Consider the following FileRoutes
/[groupId].tsx // layout
/[groupId]/(groups).tsx
/[groupId]/[matchId].tsx
/[groupId].tsx // layout
/[groupId]/(groups).tsx
/[groupId]/[matchId].tsx
Going from /groupId to /groupId/matchId will trigger [matchId]'s routeData function, but going from [matchId] to another [matchId] does not. Am I doing something wrong?
2 replies
DTDrizzle Team
Created by stiba on 3/18/2023 in #help
Applying migrations with drizzle-orm/pg-core
How would I apply all the migrations that have not yet been applied? I couldn't find any information in the docs
4 replies
CC#
Created by stiba on 3/11/2023 in #help
❔ Deploying a dotnet core application with Docker
I'm mostly used to building NodeJS applications where during development, I keep all "secrets" and appsettings in a .env file that gets loaded. When deploying to production, I just have to make sure that all the environment variables are set, and the application will work. Now, building a dotnet application I feel like this stuff is spread out a bit, and I don't know where I should put this stuff and how I should do it in production. For example: my Auth clientId/clientSecret is added by doing dotnet user-secrets set ...., but my connectionString for my postgres database is in appsettings.json. I've tried googling this but I haven't had any luck finding any good answers.
3 replies
SSolidJS
Created by stiba on 3/5/2023 in #support
solid-js reactivity eslint with functions
I'm getting the following warning: This function should be passed to a tracked scope (like createEffect) or an event handler because it contains reactivity.eslintsolid/reactivity
<MyComponent
onPriorityChanged={(priority) =>
props.onTaskPriorityChanged(task.id, priority)
}
onStatusChanged={(status) =>
props.onTaskStatusChanged(task.id, status)
}
onAssigned={(assigneeId) =>
props.onTaskAssigned(task.id, assigneeId)
}
/>
<MyComponent
onPriorityChanged={(priority) =>
props.onTaskPriorityChanged(task.id, priority)
}
onStatusChanged={(status) =>
props.onTaskStatusChanged(task.id, status)
}
onAssigned={(assigneeId) =>
props.onTaskAssigned(task.id, assigneeId)
}
/>
What am I doing wrong here? I tried looking at the eslint-plugin docs but I'm not getting any wiser
6 replies
SSolidJS
Created by stiba on 3/5/2023 in #support
routeData not being refreshed when navigating
Given the following code:
import { Show } from "solid-js";
import type { RouteDataArgs } from "solid-start";
import { useRouteData } from "solid-start";
import { createRouteData } from "solid-start";
import { api } from "~/api";
import { getFetchInit } from "~/api/utils";
import { Sidenav } from "~/components/Sidenav/Sidenav";

export const routeData = ({ params }: RouteDataArgs) => {
return createRouteData(async (_, event) => {
const { workspaceSlug, projectSlug } = params;
const init = getFetchInit(event.request.headers);

const projectsPromise = api.projects.getByWorkspaceSlug(
workspaceSlug,
init
);
const workspacePromise = api.workspaces.getDetails(
{ slug: workspaceSlug },
init
);
const tasksPromise = api.tasks.getByProjectSlug(projectSlug, init);
const membersPromise = api.workspaces.getMembers({ workspaceSlug }, init);

const [projects, workspace, tasks, members] = await Promise.all([
projectsPromise,
workspacePromise,
tasksPromise,
membersPromise,
]);

const project = projects.find((project) => project.slug === projectSlug);

if (!project) throw new Error("Project not found");

return { projects, workspace, tasks, members, project };
});
};

export default function Project() {
const data = useRouteData<typeof routeData>();

return (
<main class="flex min-h-full max-h-full">
<Show keyed when={data()}>
{(data) => (
<>
<Sidenav projects={data.projects} workspace={data.workspace} />
<section class="flex flex-col flex-grow bg-white/[0.025] min-h-full max-h-full">
<header class="flex items-center pt-4 px-6 pb-4 bg-black">
<div class="flex items-center gap-3">
<p class="capitalize">{data.workspace.name}</p>
<span>-</span>
<p class="capitalize">{data.project.name}</p>
</div>
</header>
</section>
</>
)}
</Show>
</main>
);
}
import { Show } from "solid-js";
import type { RouteDataArgs } from "solid-start";
import { useRouteData } from "solid-start";
import { createRouteData } from "solid-start";
import { api } from "~/api";
import { getFetchInit } from "~/api/utils";
import { Sidenav } from "~/components/Sidenav/Sidenav";

export const routeData = ({ params }: RouteDataArgs) => {
return createRouteData(async (_, event) => {
const { workspaceSlug, projectSlug } = params;
const init = getFetchInit(event.request.headers);

const projectsPromise = api.projects.getByWorkspaceSlug(
workspaceSlug,
init
);
const workspacePromise = api.workspaces.getDetails(
{ slug: workspaceSlug },
init
);
const tasksPromise = api.tasks.getByProjectSlug(projectSlug, init);
const membersPromise = api.workspaces.getMembers({ workspaceSlug }, init);

const [projects, workspace, tasks, members] = await Promise.all([
projectsPromise,
workspacePromise,
tasksPromise,
membersPromise,
]);

const project = projects.find((project) => project.slug === projectSlug);

if (!project) throw new Error("Project not found");

return { projects, workspace, tasks, members, project };
});
};

export default function Project() {
const data = useRouteData<typeof routeData>();

return (
<main class="flex min-h-full max-h-full">
<Show keyed when={data()}>
{(data) => (
<>
<Sidenav projects={data.projects} workspace={data.workspace} />
<section class="flex flex-col flex-grow bg-white/[0.025] min-h-full max-h-full">
<header class="flex items-center pt-4 px-6 pb-4 bg-black">
<div class="flex items-center gap-3">
<p class="capitalize">{data.workspace.name}</p>
<span>-</span>
<p class="capitalize">{data.project.name}</p>
</div>
</header>
</section>
</>
)}
</Show>
</main>
);
}
I would expect data to update when projectSlug updates. Yet it doesn't. What am I doing wrong?
6 replies
SSolidJS
Created by stiba on 1/31/2023 in #support
UND_ERR_REQ_CONTENT_LENGTH_MISMATCH error when navigating to index route
My index route looks like this
export function routeData() {
return createServerData$(async (_, { request, fetch: fetcher }) => {
const response = await fetcher("http://localhost:4000/api/users/self", {
...request,
credentials: "include",
headers: request.headers,
});

if (response.status !== 200) {
throw redirect("/login");
}

return response.json() as Promise<{ id: string }>;
});
}

const Root: VoidComponent = () => {
const data = useRouteData<typeof routeData>();
return (....)
}
export function routeData() {
return createServerData$(async (_, { request, fetch: fetcher }) => {
const response = await fetcher("http://localhost:4000/api/users/self", {
...request,
credentials: "include",
headers: request.headers,
});

if (response.status !== 200) {
throw redirect("/login");
}

return response.json() as Promise<{ id: string }>;
});
}

const Root: VoidComponent = () => {
const data = useRouteData<typeof routeData>();
return (....)
}
5 replies