Skip to content

Commit aadd394

Browse files
committed
test case for #5125
1 parent ba40ccd commit aadd394

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

drizzle-kit/tests/mysql/mysql.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,3 +2124,29 @@ test('add not null to column with default', async () => {
21242124
expect(st3).toStrictEqual(expectedSt3);
21252125
expect(pst3).toStrictEqual(expectedSt3);
21262126
});
2127+
2128+
// https://github.com/drizzle-team/drizzle-orm/issues/5125
2129+
test('case - #5125', async () => {
2130+
const students = mysqlTable('student', {
2131+
id: int().primaryKey().autoincrement(),
2132+
});
2133+
2134+
const courses = mysqlTable('course', {
2135+
id: int().primaryKey().autoincrement(),
2136+
});
2137+
2138+
const studentCourse = mysqlTable('student_course', {
2139+
studentId: int().notNull().references(() => students.id), // FK relies on PK index by default in MySQL
2140+
courseId: int().notNull().references(() => courses.id),
2141+
}, (table) => [
2142+
primaryKey({ columns: [table.studentId, table.courseId] }),
2143+
]);
2144+
2145+
const to = {
2146+
students,
2147+
courses,
2148+
studentCourse,
2149+
};
2150+
2151+
await push({ db, to });
2152+
});

0 commit comments

Comments
 (0)