drizzle-kit push not updating table schem

import { sql } from "drizzle-orm";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";

export const newsTable = sqliteTable("news", {
id: integer("id").primaryKey(),
title: text("title").notNull(),
content: text("content").notNull(),
description: text("description"),
published: text("published").notNull().default("unpublished"), // e.g., 'published', 'unpublished'
image_url: text("image_url"),
testing: text("testing"),
created_at: text("created_at").default(sql`CURRENT_TIMESTAMP`),
updated_at: text("updated_at").default(sql`CURRENT_TIMESTAMP`),
});

export type News = typeof newsTable.$inferSelect;
import { sql } from "drizzle-orm";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";

export const newsTable = sqliteTable("news", {
id: integer("id").primaryKey(),
title: text("title").notNull(),
content: text("content").notNull(),
description: text("description"),
published: text("published").notNull().default("unpublished"), // e.g., 'published', 'unpublished'
image_url: text("image_url"),
testing: text("testing"),
created_at: text("created_at").default(sql`CURRENT_TIMESTAMP`),
updated_at: text("updated_at").default(sql`CURRENT_TIMESTAMP`),
});

export type News = typeof newsTable.$inferSelect;
for example i have
testing: text("testing"),
testing: text("testing"),
when i generate and push, then the column is created but if i comment the testing and then try to generate and push, the column is still there. running on
drizzle-kit: v0.21.4
drizzle-orm: v0.30.10
drizzle-kit: v0.21.4
drizzle-orm: v0.30.10
things use to work before 21.2 now things seem buggy
1 Reply
Aliy Akhbar
Aliy AkhbarOP7mo ago
when i try to run push again i can see this
[✓] Pulling schema from database...
Warning You are about to execute current statements:

ALTER TABLE `news` RENAME TO `__old_push_news`;
CREATE TABLE `news` (
`id` integer PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`description` text,
`published` text DEFAULT 'unpublished' NOT NULL,
`image_url` text,
`testing` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "news" SELECT * FROM "__old_push_news";
DROP TABLE `__old_push_news`;
ALTER TABLE `inquiry` RENAME TO `__old_push_inquiry`;
CREATE TABLE `inquiry` (
`id` integer PRIMARY KEY NOT NULL,
`content` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);
[✓] Pulling schema from database...
Warning You are about to execute current statements:

ALTER TABLE `news` RENAME TO `__old_push_news`;
CREATE TABLE `news` (
`id` integer PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`description` text,
`published` text DEFAULT 'unpublished' NOT NULL,
`image_url` text,
`testing` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "news" SELECT * FROM "__old_push_news";
DROP TABLE `__old_push_news`;
ALTER TABLE `inquiry` RENAME TO `__old_push_inquiry`;
CREATE TABLE `inquiry` (
`id` integer PRIMARY KEY NOT NULL,
`content` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);
INSERT INTO "inquiry" SELECT * FROM "__old_push_inquiry";
DROP TABLE `__old_push_inquiry`;
ALTER TABLE `pages` RENAME TO `__old_push_pages`;
CREATE TABLE `pages` (
`id` integer PRIMARY KEY NOT NULL,
`key` text NOT NULL,
`content` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "pages" SELECT * FROM "__old_push_pages";
DROP TABLE `__old_push_pages`;
CREATE UNIQUE INDEX `pages_key_unique` ON `pages` (`key`);
ALTER TABLE `posts` RENAME TO `__old_push_posts`;
CREATE TABLE `posts` (
`id` integer PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`description` text,
`published` text DEFAULT 'unpublished' NOT NULL,
`creator_id` text NOT NULL,
`image_url` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "posts" SELECT * FROM "__old_push_posts";
DROP TABLE `__old_push_posts`;
ALTER TABLE `translations` RENAME TO `__old_push_translations`;
CREATE TABLE `translations` (
`id` integer PRIMARY KEY NOT NULL,
`key` text NOT NULL,
`locale` text NOT NULL,
`translation` text NOT NULL,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "translations" SELECT * FROM "__old_push_translations";
DROP TABLE `__old_push_translations`;

[✓] Changes applied
INSERT INTO "inquiry" SELECT * FROM "__old_push_inquiry";
DROP TABLE `__old_push_inquiry`;
ALTER TABLE `pages` RENAME TO `__old_push_pages`;
CREATE TABLE `pages` (
`id` integer PRIMARY KEY NOT NULL,
`key` text NOT NULL,
`content` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "pages" SELECT * FROM "__old_push_pages";
DROP TABLE `__old_push_pages`;
CREATE UNIQUE INDEX `pages_key_unique` ON `pages` (`key`);
ALTER TABLE `posts` RENAME TO `__old_push_posts`;
CREATE TABLE `posts` (
`id` integer PRIMARY KEY NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`description` text,
`published` text DEFAULT 'unpublished' NOT NULL,
`creator_id` text NOT NULL,
`image_url` text,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "posts" SELECT * FROM "__old_push_posts";
DROP TABLE `__old_push_posts`;
ALTER TABLE `translations` RENAME TO `__old_push_translations`;
CREATE TABLE `translations` (
`id` integer PRIMARY KEY NOT NULL,
`key` text NOT NULL,
`locale` text NOT NULL,
`translation` text NOT NULL,
`created_at` text DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text DEFAULT (CURRENT_TIMESTAMP)
);

INSERT INTO "translations" SELECT * FROM "__old_push_translations";
DROP TABLE `__old_push_translations`;

[✓] Changes applied
seems like creating new columns isnt working for me.. 😦 Running npx drizzle-kit push --verbose i can see this error:
npx drizzle-kit push --verbose

drizzle-kit: v0.21.4
drizzle-orm: v0.30.10

website/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:2143
const error2 = new ZodError(ctx.common.issues);
^

_ZodError: [
{
"expected": "'postgresql' | 'mysql' | 'sqlite'",
"received": "undefined",
"code": "invalid_type",
"path": [
"dialect"
],
"message": "Required"
}
]
at get error [as error]
npx drizzle-kit push --verbose

drizzle-kit: v0.21.4
drizzle-orm: v0.30.10

website/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:2143
const error2 = new ZodError(ctx.common.issues);
^

_ZodError: [
{
"expected": "'postgresql' | 'mysql' | 'sqlite'",
"received": "undefined",
"code": "invalid_type",
"path": [
"dialect"
],
"message": "Required"
}
]
at get error [as error]
Want results from more Discord servers?
Add your server