Report hasn't been filed before.
What version of drizzle-orm are you using?
0.45.2
What version of drizzle-kit are you using?
0.31.10
Other packages
No response
Describe the Bug
drizzle-kit push exits with code 1 on MariaDB when CHECK constraints exist (silent failure during schema pull)
drizzle-kit push fails at "Pulling schema from database..." and exits with code 1, without a useful error message, when targeting MariaDB databases that contain CHECK constraints.
Environment
- drizzle-kit: 0.31.10
- drizzle-orm: 0.45.2
- mysql2: 3.20.0
- MariaDB: 10.4.32
- Node.js: reproduced on 25.8.2 and 22.22.2
- OS: Windows
What works
- Direct mysql2 connection works
- drizzle-kit generate works
- drizzle-kit push works against a clean database
What fails
- drizzle-kit push fails against an existing MariaDB database containing CHECK constraints
Steps to reproduce
- Use MariaDB (example: 10.4.x).
- Create a table with a CHECK constraint, for example:
CREATE TABLE inventories (
id INT AUTO_INCREMENT PRIMARY KEY,
items LONGTEXT,
CONSTRAINT items CHECK (json_valid(items))
);
- Run:
npx drizzle-kit push
- Observe:
"Pulling schema from database..."
exit code 1
no actionable error printed
Expected behavior
drizzle-kit should complete introspection or print a clear error.
Actual behavior
Process exits with code 1 during schema pull.
Likely root cause
In MySQL introspection for CHECK constraints, selected columns are lower-case (table_name, constraint_name, check_clause), but the result mapping later reads upper-case keys (TABLE_NAME, CONSTRAINT_NAME, CHECK_CLAUSE). On MariaDB/mysql2 this yields undefined values, which can cause a runtime crash when writing into the table map.
##Proposed fix
Either:
Alias SQL columns to upper-case names to match current mapping, or
Read both key variants and guard missing table names.
Example safe mapping:
const constraintName = row.CONSTRAINT_NAME ?? row.constraint_name;
const constraintValue = row.CHECK_CLAUSE ?? row.check_clause;
const tableName = row.TABLE_NAME ?? row.table_name;
if (!tableName || !result[tableName]) continue;
Optional SQL alias hardening:
SELECT
tc.table_name AS TABLE_NAME,
tc.constraint_name AS CONSTRAINT_NAME,
cc.check_clause AS CHECK_CLAUSE
FROM information_schema.table_constraints tc
JOIN information_schema.check_constraints cc
ON tc.constraint_name = cc.constraint_name
WHERE tc.constraint_schema = ? AND tc.constraint_type = 'CHECK';
I can put together a PR with this fix and a test case if that helps.
Report hasn't been filed before.
What version of
drizzle-ormare you using?0.45.2
What version of
drizzle-kitare you using?0.31.10
Other packages
No response
Describe the Bug
drizzle-kit push exits with code 1 on MariaDB when CHECK constraints exist (silent failure during schema pull)
drizzle-kit push fails at "Pulling schema from database..." and exits with code 1, without a useful error message, when targeting MariaDB databases that contain CHECK constraints.
Environment
What works
What fails
Steps to reproduce
npx drizzle-kit push"Pulling schema from database..."
exit code 1
no actionable error printed
Expected behavior
drizzle-kit should complete introspection or print a clear error.
Actual behavior
Process exits with code 1 during schema pull.
Likely root cause
In MySQL introspection for CHECK constraints, selected columns are lower-case (table_name, constraint_name, check_clause), but the result mapping later reads upper-case keys (TABLE_NAME, CONSTRAINT_NAME, CHECK_CLAUSE). On MariaDB/mysql2 this yields undefined values, which can cause a runtime crash when writing into the table map.
##Proposed fix
Either:
Alias SQL columns to upper-case names to match current mapping, or
Read both key variants and guard missing table names.
Example safe mapping:
Optional SQL alias hardening:
I can put together a PR with this fix and a test case if that helps.