Open Cadienvan opened 1 year ago
Is it MySQL or Postgres?
MySQL, sorry for not mentioning it
Can't reproduce this issue. What version of drizzle-kit do you have?
@AndriiSherman we are using drizzle-kit 0.19.12.
Here's how to reproduce the issue.
Create the following table in a MySQL database:
CREATE TABLE `reproducing_issue`.`companies` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`login_provider` varchar(16) NOT NULL DEFAULT 'core',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
Now create an introspect.ts
 as follows:
import type { Config } from "drizzle-kit";
export default {
schema: "./schema-in/*",
out: "./schema-out",
driver: "mysql2",
dbCredentials: {
user: "root",
password: "root",
host: "127.0.0.1",
port: 33306,
database: "reproducing_issue",
},
} satisfies Config;
And then call this script (I added an "introspect" script in my package.json, but you can achieve the same prefixing with npx
):
drizzle-kit introspect:mysql --config=./introspect.ts
This will result in the following schema.ts
:
import { mysqlTable, mysqlSchema, AnyMySqlColumn, int, varchar } from "drizzle-orm/mysql-core"
import { sql } from "drizzle-orm"
export const companies = mysqlTable("companies", {
id: int("id").autoincrement().notNull(),
loginProvider: varchar("login_provider", { length: 16 }).default(''core'').notNull(),
});
Of course, another thing is related to the import of mysqlSchema, AnyMySqlColumn and sql which are not needed, but the main issue is caused by the ''core''
string.
I still can't reproduce it. It might also be an issue related to the MySQL version. Could you please provide the exact version of MySQL you are using? I'll try to install the same version and perform some testing
It might be in fact.. We are using a pure Docker image with mariadb:10.6
Can confirm, experiencing the same issue on 10.3.18-MariaDB-1:10.3.18+maria~bionic
.
also experiencing this issue on mariadb:10.11.0
also experiencing this issue on mariadb:11.3.0
Also seeing this, mariadb:10.4.11
drizzle-kit@0.20.17
Also seeing this on mariadb:10.6 in docker drizzle-kit@0.20.17
drizzle-kit introspect seems to generate double single quotes on every default value: