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:
@@ -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),
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user