|
| 1 | +-- Create DevTel Spec Documents table |
| 2 | +CREATE TABLE IF NOT EXISTS "devtelSpecDocuments" ( |
| 3 | + "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| 4 | + "tenantId" UUID NOT NULL, |
| 5 | + "projectId" UUID NOT NULL REFERENCES "devtelProjects"("id") ON DELETE CASCADE, |
| 6 | + "authorId" UUID NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, |
| 7 | + "title" VARCHAR(500) NOT NULL, |
| 8 | + "content" JSONB DEFAULT '{}', |
| 9 | + "status" VARCHAR(20) DEFAULT 'draft', |
| 10 | + "createdById" UUID REFERENCES "users"("id"), |
| 11 | + "updatedById" UUID REFERENCES "users"("id"), |
| 12 | + "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), |
| 13 | + "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), |
| 14 | + "deletedAt" TIMESTAMP WITH TIME ZONE |
| 15 | +); |
| 16 | + |
| 17 | +CREATE INDEX IF NOT EXISTS "devtelSpecDocuments_tenantId" ON "devtelSpecDocuments"("tenantId"); |
| 18 | +CREATE INDEX IF NOT EXISTS "devtelSpecDocuments_projectId" ON "devtelSpecDocuments"("projectId"); |
| 19 | +CREATE INDEX IF NOT EXISTS "devtelSpecDocuments_authorId" ON "devtelSpecDocuments"("authorId"); |
| 20 | +CREATE INDEX IF NOT EXISTS "devtelSpecDocuments_status" ON "devtelSpecDocuments"("status"); |
| 21 | +CREATE INDEX IF NOT EXISTS "devtelSpecDocuments_deletedAt" ON "devtelSpecDocuments"("deletedAt"); |
| 22 | + |
| 23 | +-- Create DevTel Spec Versions table |
| 24 | +CREATE TABLE IF NOT EXISTS "devtelSpecVersions" ( |
| 25 | + "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| 26 | + "specId" UUID NOT NULL REFERENCES "devtelSpecDocuments"("id") ON DELETE CASCADE, |
| 27 | + "authorId" UUID NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, |
| 28 | + "content" JSONB NOT NULL, |
| 29 | + "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), |
| 30 | + "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() |
| 31 | +); |
| 32 | + |
| 33 | +CREATE INDEX IF NOT EXISTS "devtelSpecVersions_specId" ON "devtelSpecVersions"("specId"); |
| 34 | +CREATE INDEX IF NOT EXISTS "devtelSpecVersions_authorId" ON "devtelSpecVersions"("authorId"); |
| 35 | + |
| 36 | +-- Create DevTel Spec Comments table |
| 37 | +CREATE TABLE IF NOT EXISTS "devtelSpecComments" ( |
| 38 | + "id" UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| 39 | + "specId" UUID NOT NULL REFERENCES "devtelSpecDocuments"("id") ON DELETE CASCADE, |
| 40 | + "authorId" UUID NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, |
| 41 | + "content" TEXT NOT NULL, |
| 42 | + "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), |
| 43 | + "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), |
| 44 | + "deletedAt" TIMESTAMP WITH TIME ZONE |
| 45 | +); |
| 46 | + |
| 47 | +CREATE INDEX IF NOT EXISTS "devtelSpecComments_specId" ON "devtelSpecComments"("specId"); |
| 48 | +CREATE INDEX IF NOT EXISTS "devtelSpecComments_authorId" ON "devtelSpecComments"("authorId"); |
0 commit comments