stacker.news/prisma/migrations/20230106200624_nostr_relays/migration.sql

25 lines
812 B
MySQL
Raw Normal View History

2023-01-07 00:53:09 +00:00
-- CreateTable
CREATE TABLE "NostrRelay" (
"addr" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("addr")
);
-- CreateTable
CREATE TABLE "UserNostrRelay" (
"userId" INTEGER NOT NULL,
"nostrRelayAddr" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("userId","nostrRelayAddr")
);
-- AddForeignKey
ALTER TABLE "UserNostrRelay" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "UserNostrRelay" ADD FOREIGN KEY ("nostrRelayAddr") REFERENCES "NostrRelay"("addr") ON DELETE CASCADE ON UPDATE CASCADE;