17 lines
603 B
SQL
17 lines
603 B
SQL
-- CreateTable
|
|
CREATE TABLE "ThreadSubscription" (
|
|
"userId" INTEGER NOT NULL,
|
|
"itemId" INTEGER NOT NULL,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
PRIMARY KEY ("userId","itemId")
|
|
);
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "ThreadSubscription" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "ThreadSubscription" ADD FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "ThreadSubscription.created_at_index" ON "ThreadSubscription"("created_at"); |