MrMendez
MrMendez
Explore posts from servers
DTDrizzle Team
Created by MrMendez on 9/11/2023 in #help
dynamic table name
how is that my code breaks:
const { tableName } = params;
const data = await dbPool.execute(sql`SELECT * FROM ${tableName}`);
const { tableName } = params;
const data = await dbPool.execute(sql`SELECT * FROM ${tableName}`);
but if i do this it works:
const data = await dbPool.execute(sql`SELECT * FROM account`);
const data = await dbPool.execute(sql`SELECT * FROM account`);
Error: Syntax error at or near "$1"
Location:
- serverless/index.js:1336:74 (in a module at ./node_modules/.pnpm/@neondatabase+serverless@0.6.0)
- ./src/routes/(api)/api/[table]/+server.ts:13:16
- hooks.server.ts:9:10 (at ./src)

Details:
- Error Code: 42601
- Position: 15
- File: scan.l
- Line: 1188
- Routine: scanner_yyerror

Stack trace details are available in the following modules:
- @sveltejs/kit (at ./node_modules/.pnpm/@sveltejs+kit@1.24.1_svelte@4.2.0_vite@4.4.9)
- @neondatabase/serverless (at ./node_modules/.pnpm/@neondatabase+serverless@0.6.0)
Error: Syntax error at or near "$1"
Location:
- serverless/index.js:1336:74 (in a module at ./node_modules/.pnpm/@neondatabase+serverless@0.6.0)
- ./src/routes/(api)/api/[table]/+server.ts:13:16
- hooks.server.ts:9:10 (at ./src)

Details:
- Error Code: 42601
- Position: 15
- File: scan.l
- Line: 1188
- Routine: scanner_yyerror

Stack trace details are available in the following modules:
- @sveltejs/kit (at ./node_modules/.pnpm/@sveltejs+kit@1.24.1_svelte@4.2.0_vite@4.4.9)
- @neondatabase/serverless (at ./node_modules/.pnpm/@neondatabase+serverless@0.6.0)
10 replies
DTDrizzle Team
Created by MrMendez on 9/7/2023 in #help
Migrate using Neon and Sveltekit
this is my code
import { pool } from '$lib/server/db';
import { drizzle } from 'drizzle-orm/neon-serverless';
import { migrate } from 'drizzle-orm/neon-serverless/migrator';
const db = drizzle(pool);

// this will automatically run needed migrations on the database
await migrate(db, { migrationsFolder: './migrations' });
import { pool } from '$lib/server/db';
import { drizzle } from 'drizzle-orm/neon-serverless';
import { migrate } from 'drizzle-orm/neon-serverless/migrator';
const db = drizzle(pool);

// this will automatically run needed migrations on the database
await migrate(db, { migrationsFolder: './migrations' });
pnpm script "migrate:push": "vite-node --options.transformMode.ssr='/.*/' ./src/lib/migrate.ts", my connection setup
import { Pool, neon, neonConfig } from '@neondatabase/serverless';
export const pool = new Pool({ connectionString: DB_CONNECTION_STRING });
export const http = neon(DB_CONNECTION_STRING);
import { Pool, neon, neonConfig } from '@neondatabase/serverless';
export const pool = new Pool({ connectionString: DB_CONNECTION_STRING });
export const http = neon(DB_CONNECTION_STRING);
and the error: Error: The required file "meta/_journal.json" could not be found. It seems like the "meta/_journal.json" file is missing or not located where the system expects it to be. This file is crucial for the migration process and the system cannot proceed without it. Location of the error: - File: /.../node_modules/drizzle-orm/migrator.mjs - Line: 21 - Method: readMigrationFiles Stack trace: 1. readMigrationFiles at migrator.ts:40:9 2. Module.migrate at neon-serverless/migrator.ts:9:21 3. /home/mrmendez/Projects/skymanager/src/lib/migrate.ts:7:7 4. ViteNodeRunner.runModule at vite-node/dist/client.mjs:342:5 5. ViteNodeRunner.directRequest at vite-node/dist/client.mjs:326:5 6. ViteNodeRunner.cachedRequest at vite-node/dist/client.mjs:189:14 7. ViteNodeRunner.executeFile at vite-node/dist/client.mjs:161:12 8. CAC.run at vite-node/dist/cli.mjs:91:5
15 replies