From 33d66bc7c4a7af6a64e0b4da457ebd6be805a414 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Sun, 26 Apr 2026 20:36:26 +0200 Subject: [PATCH] feat(ST-507): add optional code fields to Product, Pbi and Story Co-Authored-By: Claude Opus 4.7 (1M context) --- docs/erd.svg | 2 +- .../20260426202231_add_entity_codes/migration.sql | 9 +++++++++ prisma/schema.prisma | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20260426202231_add_entity_codes/migration.sql diff --git a/docs/erd.svg b/docs/erd.svg index 7011ffd..5ee4b12 100644 --- a/docs/erd.svg +++ b/docs/erd.svg @@ -1 +1 @@ -

user

enum:role

user

user

product

pbi

product

sprint

assignee

enum:status

story

enum:type

enum:status

product

enum:status

story

sprint

enum:status

product

user

user

product

Role

PRODUCT_OWNER

PRODUCT_OWNER

SCRUM_MASTER

SCRUM_MASTER

DEVELOPER

DEVELOPER

StoryStatus

OPEN

OPEN

IN_SPRINT

IN_SPRINT

DONE

DONE

TaskStatus

TO_DO

TO_DO

IN_PROGRESS

IN_PROGRESS

REVIEW

REVIEW

DONE

DONE

LogType

IMPLEMENTATION_PLAN

IMPLEMENTATION_PLAN

TEST_RESULT

TEST_RESULT

COMMIT

COMMIT

TestStatus

PASSED

PASSED

FAILED

FAILED

SprintStatus

ACTIVE

ACTIVE

COMPLETED

COMPLETED

users

String

id

🗝️

String

username

String

email

String

password_hash

Boolean

is_demo

String

bio

String

bio_detail

Bytes

avatar_data

DateTime

created_at

DateTime

updated_at

user_roles

String

id

🗝️

Role

role

api_tokens

String

id

🗝️

String

token_hash

String

label

DateTime

created_at

DateTime

revoked_at

products

String

id

🗝️

String

name

String

description

String

repo_url

String

definition_of_done

Boolean

archived

DateTime

created_at

DateTime

updated_at

pbis

String

id

🗝️

String

title

String

description

Int

priority

Float

sort_order

DateTime

created_at

DateTime

updated_at

stories

String

id

🗝️

String

title

String

description

String

acceptance_criteria

Int

priority

Float

sort_order

StoryStatus

status

DateTime

created_at

DateTime

updated_at

story_logs

String

id

🗝️

LogType

type

String

content

TestStatus

status

String

commit_hash

String

commit_message

DateTime

created_at

sprints

String

id

🗝️

String

sprint_goal

SprintStatus

status

DateTime

created_at

DateTime

completed_at

tasks

String

id

🗝️

String

title

String

description

String

implementation_plan

Int

priority

Float

sort_order

TaskStatus

status

DateTime

created_at

DateTime

updated_at

product_members

String

id

🗝️

DateTime

created_at

todos

String

id

🗝️

String

title

String

description

Boolean

done

Boolean

archived

DateTime

created_at

DateTime

updated_at

\ No newline at end of file +

user

enum:role

user

user

product

pbi

product

sprint

assignee

enum:status

story

enum:type

enum:status

product

enum:status

story

sprint

enum:status

product

user

user

product

Role

PRODUCT_OWNER

PRODUCT_OWNER

SCRUM_MASTER

SCRUM_MASTER

DEVELOPER

DEVELOPER

StoryStatus

OPEN

OPEN

IN_SPRINT

IN_SPRINT

DONE

DONE

TaskStatus

TO_DO

TO_DO

IN_PROGRESS

IN_PROGRESS

REVIEW

REVIEW

DONE

DONE

LogType

IMPLEMENTATION_PLAN

IMPLEMENTATION_PLAN

TEST_RESULT

TEST_RESULT

COMMIT

COMMIT

TestStatus

PASSED

PASSED

FAILED

FAILED

SprintStatus

ACTIVE

ACTIVE

COMPLETED

COMPLETED

users

String

id

🗝️

String

username

String

email

String

password_hash

Boolean

is_demo

String

bio

String

bio_detail

Bytes

avatar_data

DateTime

created_at

DateTime

updated_at

user_roles

String

id

🗝️

Role

role

api_tokens

String

id

🗝️

String

token_hash

String

label

DateTime

created_at

DateTime

revoked_at

products

String

id

🗝️

String

name

String

code

String

description

String

repo_url

String

definition_of_done

Boolean

archived

DateTime

created_at

DateTime

updated_at

pbis

String

id

🗝️

String

code

String

title

String

description

Int

priority

Float

sort_order

DateTime

created_at

DateTime

updated_at

stories

String

id

🗝️

String

code

String

title

String

description

String

acceptance_criteria

Int

priority

Float

sort_order

StoryStatus

status

DateTime

created_at

DateTime

updated_at

story_logs

String

id

🗝️

LogType

type

String

content

TestStatus

status

String

commit_hash

String

commit_message

DateTime

created_at

sprints

String

id

🗝️

String

sprint_goal

SprintStatus

status

DateTime

created_at

DateTime

completed_at

tasks

String

id

🗝️

String

title

String

description

String

implementation_plan

Int

priority

Float

sort_order

TaskStatus

status

DateTime

created_at

DateTime

updated_at

product_members

String

id

🗝️

DateTime

created_at

todos

String

id

🗝️

String

title

String

description

Boolean

done

Boolean

archived

DateTime

created_at

DateTime

updated_at

\ No newline at end of file diff --git a/prisma/migrations/20260426202231_add_entity_codes/migration.sql b/prisma/migrations/20260426202231_add_entity_codes/migration.sql new file mode 100644 index 0000000..ecf5565 --- /dev/null +++ b/prisma/migrations/20260426202231_add_entity_codes/migration.sql @@ -0,0 +1,9 @@ +-- AlterTable +ALTER TABLE "products" ADD COLUMN "code" VARCHAR(30); +ALTER TABLE "pbis" ADD COLUMN "code" VARCHAR(30); +ALTER TABLE "stories" ADD COLUMN "code" VARCHAR(30); + +-- CreateIndex +CREATE UNIQUE INDEX "products_user_id_code_key" ON "products"("user_id", "code"); +CREATE UNIQUE INDEX "pbis_product_id_code_key" ON "pbis"("product_id", "code"); +CREATE UNIQUE INDEX "stories_product_id_code_key" ON "stories"("product_id", "code"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index bf68dba..6acf5a1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -95,6 +95,7 @@ model Product { user User @relation(fields: [user_id], references: [id], onDelete: Cascade) user_id String name String + code String? @db.VarChar(30) description String? repo_url String? definition_of_done String @@ -108,6 +109,7 @@ model Product { members ProductMember[] @@unique([user_id, name]) + @@unique([user_id, code]) @@index([user_id, archived]) @@map("products") } @@ -116,6 +118,7 @@ model Pbi { id String @id @default(cuid()) product Product @relation(fields: [product_id], references: [id], onDelete: Cascade) product_id String + code String? @db.VarChar(30) title String description String? priority Int @@ -124,6 +127,7 @@ model Pbi { updated_at DateTime @updatedAt stories Story[] + @@unique([product_id, code]) @@index([product_id, priority, sort_order]) @@map("pbis") } @@ -138,6 +142,7 @@ model Story { sprint_id String? assignee User? @relation("StoryAssignee", fields: [assignee_id], references: [id], onDelete: SetNull) assignee_id String? + code String? @db.VarChar(30) title String description String? acceptance_criteria String? @@ -149,6 +154,7 @@ model Story { logs StoryLog[] tasks Task[] + @@unique([product_id, code]) @@index([pbi_id, priority, sort_order]) @@index([sprint_id, sort_order]) @@index([product_id, status])