N
Neon5mo ago
flat-fuchsia

How to migrate tables from local to neon?

I am using docker for local development using postgres but when I run pnpm drizzle-kit migrate it show me success message migrations applied but when i check neon tables there is nothing. no tables. I confirm I have changed the database connection string in the env with neon. I have followed this guide to create docker setup https://neon.tech/guides/drizzle-local-vercel That's confusing because after success message there should be tables but not. lib/db/index.ts
import "dotenv/config";
import { Pool, neonConfig } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";
import { WebSocket } from "ws";
import * as schema from "./schema";

if (process.env.NODE_ENV === "production") {
neonConfig.webSocketConstructor = WebSocket;
neonConfig.poolQueryViaFetch = true;
} else {
neonConfig.webSocketConstructor = WebSocket;
neonConfig.wsProxy = (host) => `${host}:5433/v1`;
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;
neonConfig.pipelineConnect = false;
}

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

export const db = drizzle(pool, { schema });

export type db = typeof db;
import "dotenv/config";
import { Pool, neonConfig } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";
import { WebSocket } from "ws";
import * as schema from "./schema";

if (process.env.NODE_ENV === "production") {
neonConfig.webSocketConstructor = WebSocket;
neonConfig.poolQueryViaFetch = true;
} else {
neonConfig.webSocketConstructor = WebSocket;
neonConfig.wsProxy = (host) => `${host}:5433/v1`;
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;
neonConfig.pipelineConnect = false;
}

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

export const db = drizzle(pool, { schema });

export type db = typeof db;
docker-compose.yml
services:
postgres:
image: 'postgres:17'
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- '5432:5432'

pg_proxy:
image: ghcr.io/neondatabase/wsproxy:latest
environment:
APPEND_PORT: 'postgres:5432'
ALLOW_ADDR_REGEX: '.*'
LOG_TRAFFIC: 'true'
ports:
- '5433:80'
depends_on:
- postgres
services:
postgres:
image: 'postgres:17'
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- '5432:5432'

pg_proxy:
image: ghcr.io/neondatabase/wsproxy:latest
environment:
APPEND_PORT: 'postgres:5432'
ALLOW_ADDR_REGEX: '.*'
LOG_TRAFFIC: 'true'
ports:
- '5433:80'
depends_on:
- postgres
drizzle.config.ts
import "dotenv/config";
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./lib/db/schema/index.ts",
out: "./lib/db/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
import "dotenv/config";
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./lib/db/schema/index.ts",
out: "./lib/db/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
Neon
Drizzle with Local and Serverless Postgres - Neon Guides
A step-by-step guide to configure Drizzle ORM for local and serverless Postgres.
3 Replies
flat-fuchsia
flat-fuchsiaOP5mo ago
@Rishi Raj Jain bro can you help?? @Mahmoud any help??
national-gold
national-gold5mo ago
Can you prehaps log the connection string? that's only thing I can think of
flat-fuchsia
flat-fuchsiaOP5mo ago
yes connection string is working and correct that's why it gives me the message migration applied successfully

Did you find this page helpful?