Motomo
Motomo
DTDrizzle Team
Created by Eko on 5/23/2023 in #help
Select with relation
Ok stypid mistake on my part I just reused the url of the database from Prisma and they use a ?schema=public instead of ?search_path=public in the Url
21 replies
DTDrizzle Team
Created by Eko on 5/23/2023 in #help
Select with relation
I even tried with a schema of a single table and got the same issue trying to run
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
import 'dotenv/config'
import path from "path";
import { readdirSync } from "fs";

const connectionString = process.env.DATABASE_URL as string;
const sql = postgres(connectionString, { max: 1 });
const db = drizzle(sql);

async function run() {
const migrationsFolder = path.join(__dirname, '..', 'drizzle');
console.log(readdirSync(migrationsFolder))
await migrate(db, { migrationsFolder });
process.exit(0);
}

run();
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
import 'dotenv/config'
import path from "path";
import { readdirSync } from "fs";

const connectionString = process.env.DATABASE_URL as string;
const sql = postgres(connectionString, { max: 1 });
const db = drizzle(sql);

async function run() {
const migrationsFolder = path.join(__dirname, '..', 'drizzle');
console.log(readdirSync(migrationsFolder))
await migrate(db, { migrationsFolder });
process.exit(0);
}

run();
So I pushed the schema (this worked correclty) but when trying to run a query in the code got the same issue
@Injectable()
export class PostgresService implements OnModuleInit {
db: PostgresJsDatabase<typeof schema>;
constructor(private readonly config: ConfigService) { }

onModuleInit() {
console.log(this.config.databaseUrl())
const client = postgres(this.config.databaseUrl());
this.db = drizzle(client, { schema });
}
}
@Injectable()
export class PostgresService implements OnModuleInit {
db: PostgresJsDatabase<typeof schema>;
constructor(private readonly config: ConfigService) { }

onModuleInit() {
console.log(this.config.databaseUrl())
const client = postgres(this.config.databaseUrl());
this.db = drizzle(client, { schema });
}
}
(I checked that everything was defined correcly (schema path, db url))
21 replies
DTDrizzle Team
Created by Eko on 5/23/2023 in #help
Select with relation
Hey there, I just setup drizzle and got the same error can you point me to a direction on how you fixed it ?
21 replies