Issue with schema migration on neon

Hi, I want to migrate schema of my database. I have a table called "tokens" to which I want to add two columns. I'm running the following command:
yarn drizzle-kit generate --config ./drizzle.neon.config.ts
yarn drizzle-kit generate --config ./drizzle.neon.config.ts
And this is the config file:
import { defineConfig } from "drizzle-kit"
import "dotenv/config"

export default defineConfig({
out: "./drizzle-neon",
schema: "./src/app/api/database/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.POSTGRES_TOKENS_DATABASE_URL as string,
},
})
import { defineConfig } from "drizzle-kit"
import "dotenv/config"

export default defineConfig({
out: "./drizzle-neon",
schema: "./src/app/api/database/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.POSTGRES_TOKENS_DATABASE_URL as string,
},
})
After I run the command a new file gets generated and it's the following:
CREATE TABLE "tokens" (
"chainId" bigint NOT NULL,
"address" varchar NOT NULL,
"logoURI" varchar,
"name" varchar NOT NULL,
"symbol" varchar NOT NULL,
"decimals" integer NOT NULL,
"priceUSD" varchar,
"marketCapUSD" double precision,
"volumeUSD24H" double precision,
"updatedAt" bigint NOT NULL,
CONSTRAINT "tokens_chainId_address_pk" PRIMARY KEY("chainId","address")
);
--> statement-breakpoint
CREATE INDEX "chainId_idx" ON "tokens" USING btree ("chainId");--> statement-breakpoint
CREATE INDEX "address_idxs" ON "tokens" USING btree ("address");
CREATE TABLE "tokens" (
"chainId" bigint NOT NULL,
"address" varchar NOT NULL,
"logoURI" varchar,
"name" varchar NOT NULL,
"symbol" varchar NOT NULL,
"decimals" integer NOT NULL,
"priceUSD" varchar,
"marketCapUSD" double precision,
"volumeUSD24H" double precision,
"updatedAt" bigint NOT NULL,
CONSTRAINT "tokens_chainId_address_pk" PRIMARY KEY("chainId","address")
);
--> statement-breakpoint
CREATE INDEX "chainId_idx" ON "tokens" USING btree ("chainId");--> statement-breakpoint
CREATE INDEX "address_idxs" ON "tokens" USING btree ("address");
But I already have a tokens table in my neon db, so why is the drizzle-kit generating this? I can't do much with this query since the table in question already exists. Shouldn't it be an alter statement instead? Thank you
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?