feat: add states CRUD API route with project-scoped workflow states

- Add states.ts with GET/POST/PATCH/DELETE endpoints
- States scoped to project via projectId FK; workspace access resolved through project
- stateGroupEnum enforced (backlog|unstarted|started|completed|cancelled)
- List ordered by sortOrder, auto-increment on create
- Soft-delete via deletedAt column (added to schema)
- 3-step contract on every write: DB write, activity feed, pg_notify
- Register /api/states route in main index.ts
- Default state seeding already present in projects.ts
This commit is contained in:
2026-09-07 19:24:24 +00:00
parent 583c476e12
commit c5682765e8
3 changed files with 246 additions and 0 deletions
+2
View File
@@ -160,10 +160,12 @@ export const states = pgTable(
sortOrder: integer('sort_order').default(0),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
deletedAt: timestamp('deleted_at', { withTimezone: true }),
},
(table) => [
index('states_project_id_idx').on(table.projectId),
index('states_sort_order_idx').on(table.projectId, table.sortOrder),
index('states_deleted_at_idx').on(table.deletedAt),
]
);