Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]:drizzle-kit pull generate wrong schema.ts #3559

Open
1 task done
qazwsxedckll opened this issue Nov 15, 2024 · 3 comments
Open
1 task done

[BUG]:drizzle-kit pull generate wrong schema.ts #3559

qazwsxedckll opened this issue Nov 15, 2024 · 3 comments
Assignees
Labels
bug Something isn't working db/mysql drizzle/kit has-pr This issue has one or more PRs that that could close the issue when merged priority Will be worked on next

Comments

@qazwsxedckll
Copy link

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.36.2

What version of drizzle-kit are you using?

0.28.0

Other packages

No response

Describe the Bug

Using Mysql 8.0.39

Table DDL

CREATE TABLE `alert_history` (
`id` bigint AUTO_INCREMENT NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL DEFAULT '',
`message` varchar(255) NOT NULL DEFAULT '',
`time` timestamp NOT NULL,
`alert_type` varchar(255) NOT NULL,
`priority` int NOT NULL,
`event_name` varchar(255) NOT NULL,
`origin` varchar(255) NOT NULL DEFAULT '',
`origin_property` varchar(255) NOT NULL DEFAULT '',
`origin_property_basetype` varchar(255) NOT NULL DEFAULT '',
CONSTRAINT `alert_history_id` PRIMARY KEY(`id`)
);

generated schema.ts

export const alertHistory = mysqlTable("alert_history", {
	id: bigint({ mode: "number" }).autoincrement().notNull(),
	name: varchar({ length: 255 }).notNull(),
	description: varchar({ length: 255 }).default(').notNull(),
	message: varchar({ length: 255 }).default(').notNull(),
	time: timestamp({ mode: 'string' }).notNull(),
	alertType: varchar("alert_type", { length: 255 }).notNull(),
	priority: int().notNull(),
	eventName: varchar("event_name", { length: 255 }).notNull(),
	origin: varchar({ length: 255 }).default(').notNull(),
	originProperty: varchar("origin_property", { length: 255 }).default(').notNull(),
	originPropertyBasetype: varchar("origin_property_basetype", { length: 255 }).default(').notNull(),
},
(table) => {
	return {
		idxEntityIdTime: index("idx_entity_id_time").on(table.time),
		idxEntityIdName: index("idx_entity_id_name").on(table.name),
		idxTime: index("idx_time").on(table.time),
		alertHistoryId: primaryKey({ columns: [table.id], name: "alert_history_id"}),
	}
});

the default empty string is missing one '

@qazwsxedckll qazwsxedckll added the bug Something isn't working label Nov 15, 2024
@jpx15
Copy link

jpx15 commented Nov 27, 2024

I have just encountered this bug as well. Exact same description column constraints/defaults.

@lucaswinningham
Copy link

lucaswinningham commented Nov 27, 2024

Same here with postgres dialect.

@natehouk
Copy link

+1

@L-Mario564 L-Mario564 added db/mysql has-pr This issue has one or more PRs that that could close the issue when merged and removed db/postgres labels Feb 4, 2025
@L-Mario564 L-Mario564 self-assigned this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working db/mysql drizzle/kit has-pr This issue has one or more PRs that that could close the issue when merged priority Will be worked on next
Projects
None yet
Development

No branches or pull requests

5 participants