multica/server/migrations/024_backfill_empty_issue_prefix.up.sql
Jiayuan f5519e4f64 fix(handler): set issue_prefix when auto-creating workspace on first login
ensureUserWorkspace in auth.go omitted the IssuePrefix field when
creating a default workspace during first login. This caused the
workspace's issue_prefix to be empty, producing identifiers like "-16"
instead of "JIA-16".

- Pass generateIssuePrefix(wsName) when creating the default workspace
- Add fallback in getIssuePrefix to regenerate from workspace name if
  the stored prefix is empty
- Add migration 024 to backfill empty prefixes on existing workspaces
2026-03-30 13:26:42 +08:00

8 lines
413 B
SQL

-- Backfill workspaces that have an empty issue_prefix (e.g. auto-created
-- during first login before the prefix was wired up in ensureUserWorkspace).
UPDATE workspace SET issue_prefix = UPPER(
LEFT(REGEXP_REPLACE(name, '[^a-zA-Z]', '', 'g'), 3)
) WHERE issue_prefix = '';
-- Fallback for workspaces whose name has no alphabetic characters.
UPDATE workspace SET issue_prefix = 'WS' WHERE issue_prefix = '';