mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-18 22:51:40 +03:00
f9e8f88b66
- `wasp db migrate-save` and `wasp db migrate-up` got replaced with `wasp db migrate-dev`. - Wasp now has a declarative way to express which db is used, postgresql or sqlite: `db { system: PostgreSQL }`. - Prisma is now at the latest version, 2.21. PSL parser was upgraded to work with this. - PostgreSQL can now be used for local development. - We migrated examples/realworld to work with this new version of Wasp.
116 lines
3.2 KiB
SQL
116 lines
3.2 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "User" (
|
|
"id" SERIAL NOT NULL,
|
|
"username" TEXT NOT NULL,
|
|
"email" TEXT NOT NULL,
|
|
"password" TEXT NOT NULL,
|
|
"bio" TEXT,
|
|
"profilePictureUrl" TEXT,
|
|
|
|
PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Article" (
|
|
"id" SERIAL NOT NULL,
|
|
"slug" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
"title" TEXT NOT NULL,
|
|
"description" TEXT NOT NULL,
|
|
"markdownContent" TEXT NOT NULL,
|
|
"userId" INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Comment" (
|
|
"id" SERIAL NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"content" TEXT NOT NULL,
|
|
"userId" INTEGER NOT NULL,
|
|
"articleId" INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "ArticleTag" (
|
|
"name" TEXT NOT NULL,
|
|
|
|
PRIMARY KEY ("name")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "_FavoritedArticles" (
|
|
"A" INTEGER NOT NULL,
|
|
"B" INTEGER NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "_FollowedUser" (
|
|
"A" INTEGER NOT NULL,
|
|
"B" INTEGER NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "_ArticleToArticleTag" (
|
|
"A" INTEGER NOT NULL,
|
|
"B" TEXT NOT NULL
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "User.username_unique" ON "User"("username");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Article.slug_unique" ON "Article"("slug");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "_FavoritedArticles_AB_unique" ON "_FavoritedArticles"("A", "B");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "_FavoritedArticles_B_index" ON "_FavoritedArticles"("B");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "_FollowedUser_AB_unique" ON "_FollowedUser"("A", "B");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "_FollowedUser_B_index" ON "_FollowedUser"("B");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "_ArticleToArticleTag_AB_unique" ON "_ArticleToArticleTag"("A", "B");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "_ArticleToArticleTag_B_index" ON "_ArticleToArticleTag"("B");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Article" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Comment" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Comment" ADD FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_FavoritedArticles" ADD FOREIGN KEY ("A") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_FavoritedArticles" ADD FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_FollowedUser" ADD FOREIGN KEY ("A") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_FollowedUser" ADD FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_ArticleToArticleTag" ADD FOREIGN KEY ("A") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_ArticleToArticleTag" ADD FOREIGN KEY ("B") REFERENCES "ArticleTag"("name") ON DELETE CASCADE ON UPDATE CASCADE;
|