aspasht
aspasht
DTDrizzle Team
Created by aspasht on 9/1/2024 in #help
Vercel integration setup
Uncaught (in promise) VercelPostgresError: VercelPostgresError - 'missing_connection_string': You did not supply a 'connectionString' and no 'POSTGRES_URL' env var was found. I'm trying to connect vercel postgres in my nextjs project with drizzle orm. I've followed official documentation from vercel , also drizzle but still facing this issue. Did anyone ran into this issue before?
1 replies
DTDrizzle Team
Created by aspasht on 5/19/2024 in #help
Migrating to the latest version of drizzle-kit.
import { defineConfig } from "drizzle-kit"

export default defineConfig({
dialect: 'postgresql',
dbCredentials: {
url: EnvConfig.DATABASE_URL,
},
// migrations:{
// table: "migrations",
// schema:'public',
// }
})
import { defineConfig } from "drizzle-kit"

export default defineConfig({
dialect: 'postgresql',
dbCredentials: {
url: EnvConfig.DATABASE_URL,
},
// migrations:{
// table: "migrations",
// schema:'public',
// }
})
import { migrate } from "drizzle-orm/postgres-js/migrator";
import { db } from "../config/db";

export const runMigrations = async () => {
await migrate(db, {
migrationsFolder: "./migrations",
});
};
import { migrate } from "drizzle-orm/postgres-js/migrator";
import { db } from "../config/db";

export const runMigrations = async () => {
await migrate(db, {
migrationsFolder: "./migrations",
});
};
drizzle-kit: v0.21.2 drizzle-orm: v0.30.10 No config path provided, using default 'drizzle.config.ts' Reading config file '/drizzle.config.ts' You have to provide 'schema' param why I'm getting this error and how do i provide 'schema' param?
4 replies
DTDrizzle Team
Created by aspasht on 5/11/2024 in #help
creating graphql mutation
//index.ts
import 'dotenv/config'
import { createYoga } from 'graphql-yoga';
import { createServer } from 'node:http';
import { buildSchema } from 'drizzle-graphql';
import { db } from './config/db';

const { schema } = buildSchema(db);
const yoga = createYoga({ schema });
const server = createServer(yoga);
server.listen(4000, () => {
console.info('Server is running on http://localhost:4000/graphql');
});
//index.ts
import 'dotenv/config'
import { createYoga } from 'graphql-yoga';
import { createServer } from 'node:http';
import { buildSchema } from 'drizzle-graphql';
import { db } from './config/db';

const { schema } = buildSchema(db);
const yoga = createYoga({ schema });
const server = createServer(yoga);
server.listen(4000, () => {
console.info('Server is running on http://localhost:4000/graphql');
});
//schema.ts
import { pgTable,uuid,varchar} from 'drizzle-orm/pg-core'
export const posts = pgTable("posts",{
id: uuid("id").primaryKey().defaultRandom(),
title: varchar("title",{length:255}).notNull(),
description:varchar("description",{length:255}).notNull(),
content:varchar("content",{length:255}).notNull(),
})
//schema.ts
import { pgTable,uuid,varchar} from 'drizzle-orm/pg-core'
export const posts = pgTable("posts",{
id: uuid("id").primaryKey().defaultRandom(),
title: varchar("title",{length:255}).notNull(),
description:varchar("description",{length:255}).notNull(),
content:varchar("content",{length:255}).notNull(),
})
//db.ts
const queryClient = postgres(EnvConfig.DATABASE_URL)

export const db = drizzle(queryClient,{schema:dbSchema})
//db.ts
const queryClient = postgres(EnvConfig.DATABASE_URL)

export const db = drizzle(queryClient,{schema:dbSchema})
//resolvers.ts
import { posts } from "../drizzle/schema";
import { db } from "../config/db";
import { YogaInitialContext } from "graphql-yoga";

export const resolvers = {
Query: {
posts: async () => {
await db.select().from(posts).unionAll;
},
},
Mutation: {
createPost: async () => {
await db.insert(posts).values({id,title,content,description}).returning();
},
},
};
//resolvers.ts
import { posts } from "../drizzle/schema";
import { db } from "../config/db";
import { YogaInitialContext } from "graphql-yoga";

export const resolvers = {
Query: {
posts: async () => {
await db.select().from(posts).unionAll;
},
},
Mutation: {
createPost: async () => {
await db.insert(posts).values({id,title,content,description}).returning();
},
},
};
these are my configs. Now i want to write mutations to create a post. how can i do that ? I tried but I got type mismatch everytime.
1 replies