wasp/examples/realworld/migrations/20201124195623-added-slug-to-article
2020-11-24 21:11:37 +01:00
..
README.md Added article slug. 2020-11-24 21:11:37 +01:00
schema.prisma Added article slug. 2020-11-24 21:11:37 +01:00
steps.json Added article slug. 2020-11-24 21:11:37 +01:00

Migration 20201124195623-added-slug-to-article

This migration has been generated by Martin Sosic at 11/24/2020, 8:56:23 PM. You can check out the state of the schema after the migration.

Database Steps

CREATE TABLE "User" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "username" TEXT NOT NULL,
    "email" TEXT NOT NULL,
    "password" TEXT NOT NULL,
    "bio" TEXT,
    "profilePictureUrl" TEXT
)

CREATE TABLE "Article" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "slug" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    "title" TEXT NOT NULL,
    "description" TEXT NOT NULL,
    "markdownContent" TEXT NOT NULL,
    "userId" INTEGER NOT NULL,

    FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
)

CREATE UNIQUE INDEX "User.username_unique" ON "User"("username")

CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")

CREATE UNIQUE INDEX "Article.slug_unique" ON "Article"("slug")

Changes

diff --git schema.prisma schema.prisma
migration 20201124192901-added-created-at-to-article..20201124195623-added-slug-to-article
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
 datasource db {
   provider = "sqlite"
-  url = "***"
+  url = "***"
 }
 generator client {
   provider = "prisma-client-js"
@@ -20,9 +20,11 @@
 }
 model Article {
     id              Int      @id @default(autoincrement())
+    slug            String   @unique
     createdAt       DateTime @default(now())
+    updatedAt       DateTime @updatedAt
     title           String
     description     String
     markdownContent String
     user            User     @relation(fields: [userId], references: [id])