Replaces the hardcoded PROJECT_CODES array with an admin-managed `ProjectCode` model, mirroring the Delivery Locations pattern (PR #100): - ProjectCode model (unique `code` + isActive) + migration seeding the five previously-hardcoded codes; PO.projectCode stays a free-text snapshot (no FK) so history/exports/imports are unchanged. - manage_project_codes permission (Manager + SuperUser + Admin). - /admin/project-codes CRUD screen (table + Add/Edit + activate/delete) and an Administration sidebar link. - ProjectCodeField now takes `options` from the active codes; the three PO forms + pages fetch them from the DB. Static list removed. - Unit test reworked to the options API; CRUD integration test added; documented in App/CLAUDE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
907 B
SQL
22 lines
907 B
SQL
-- CreateTable
|
|
CREATE TABLE "ProjectCode" (
|
|
"id" TEXT NOT NULL,
|
|
"code" TEXT NOT NULL,
|
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "ProjectCode_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "ProjectCode_code_key" ON "ProjectCode"("code");
|
|
|
|
-- Seed the previously-hardcoded project codes so the dropdown stays populated
|
|
-- after this feature replaces the static list (issue #124).
|
|
INSERT INTO "ProjectCode" ("id", "code", "updatedAt") VALUES
|
|
('pcseed_petronet', 'Petronet LNG Cochin', CURRENT_TIMESTAMP),
|
|
('pcseed_comacoe_trombay', 'COMACOE Trombay', CURRENT_TIMESTAMP),
|
|
('pcseed_haldia_reach', 'Haldia Reach', CURRENT_TIMESTAMP),
|
|
('pcseed_haldia_mmt', 'Haldia MMT', CURRENT_TIMESTAMP),
|
|
('pcseed_comacoe_mandvi', 'COMACOE Mandvi', CURRENT_TIMESTAMP);
|