© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
4 replies
bkyerv

Strugling to use composite key in schema

How do I represent composite primary key in drizzle way (sqlite) below migration query? I red the docs but failed miserable in trying to implement it.
CREATE TABLE QuestionSetMapping (
    SetID INTEGER,
    QuestionID INTEGER,
    PRIMARY KEY(SetID, QuestionID),
    FOREIGN KEY(SetID) REFERENCES QuestionSets(SetID),
    FOREIGN KEY(QuestionID) REFERENCES Questions(QuestionID)
);
CREATE TABLE QuestionSetMapping (
    SetID INTEGER,
    QuestionID INTEGER,
    PRIMARY KEY(SetID, QuestionID),
    FOREIGN KEY(SetID) REFERENCES QuestionSets(SetID),
    FOREIGN KEY(QuestionID) REFERENCES Questions(QuestionID)
);
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to use "onConflictDoUpdate" with composite key?
Drizzle TeamDTDrizzle Team / help
3y ago
How to use a composite primary key in WHERE?
Drizzle TeamDTDrizzle Team / help
3y ago
How to reference composite key in foreign key
Drizzle TeamDTDrizzle Team / help
2y ago
Composite Primary Key?
Drizzle TeamDTDrizzle Team / help
16mo ago