Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
-- Remove leading zeros from existing short codes, relax the minimum length constraint,
-- and add creator tracking columns.

-- Drop the old constraint first (required min 4 chars) so the UPDATE below can produce shorter codes
ALTER TABLE url_mappings
DROP CONSTRAINT chk_short_code_format;

-- Strip leading zeros from all existing short codes
UPDATE url_mappings
SET short_code = LTRIM(short_code, '0')
WHERE short_code ~ '^0+.+$';

-- Update the format constraint to allow codes as short as 1 character
ALTER TABLE url_mappings
DROP CONSTRAINT chk_short_code_format,
ADD CONSTRAINT chk_short_code_format CHECK (short_code ~ '^[0-9a-zA-Z_-]{1,32}$');

-- Add creator tracking columns
Expand Down
Loading