railyard/apps/console/db/migrations/0011_signup_attribution.sql
caelum0x 91d6f2717a feat(console,insights): console cross-sell bridge with signup attribution
Prefilled /auth/start?email=&src=insights deep link from the Insights
dashboard banner into Console signup, with first-touch attribution
recorded on the new org (migration 0011, signup_source column) so the
only proven self-serve funnel (Insights) now converts into Console
signups instead of dead-ending.
2026-10-23 15:35:31 +03:00

16 lines
698 B
SQL

-- Console cross-sell bridge (RYP-X1): first-touch signup attribution.
-- Records where a new org's owner first clicked through from (e.g.
-- "insights" for the Insights dashboard banner), written once at org
-- creation by lib/signin.ts via lib/session.ts's SRC_COOKIE. Idempotent.
alter table railyard.orgs
add column if not exists signup_source text;
alter table railyard.orgs
drop constraint if exists orgs_signup_source_format;
alter table railyard.orgs
add constraint orgs_signup_source_format
check (signup_source is null or signup_source ~ '^[a-z0-9_-]{1,40}$');
create index if not exists orgs_signup_source_idx on railyard.orgs (signup_source) where signup_source is not null;