mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-19 08:01:16 +00:00
11 lines
362 B
SQL
11 lines
362 B
SQL
ALTER TABLE sequences ADD COLUMN IF NOT EXISTS position INT NOT NULL DEFAULT 0;
|
|
|
|
-- Backfill position based on existing creation order per campaign
|
|
WITH ranked AS (
|
|
SELECT id, ROW_NUMBER() OVER (PARTITION BY campaign_id ORDER BY created_at ASC) AS rn
|
|
FROM sequences
|
|
)
|
|
UPDATE sequences SET position = ranked.rn
|
|
FROM ranked
|
|
WHERE sequences.id = ranked.id;
|