Add visibility column to links table #30

Open
opened 2026-06-08 03:20:05 +00:00 by ldraney · 0 comments
Owner

Type

Feature

Lineage

Follow-up from spikes #16 (docs/auth.md) and #17 (docs/visibility.md).

Repo

ldraney/palinks

User Story

As Lucas
I want each link to have a visibility level
So that I can control which audience sees which links

Context

The visibility system uses three tiers: public, member, superadmin. Default is superadmin (safe — new links are private until shared). This migration ships before auth is wired up — all existing links get superadmin, meaning no behavioral change until filtering is added in a separate ticket.

File Targets

  • db/migrate/xxx_add_visibility_to_links.rb — new migration
  • app/models/link.rb — add VISIBILITY_LEVELS, VISIBILITY_HIERARCHY, visible_to scope, validation

Feature Flag

None — schema change with no visible behavior until filtering is wired up.

Acceptance Criteria

  • Migration adds visibility: string, default: "superadmin", null: false
  • Check constraint limits values to public, member, superadmin
  • Link.visible_to("superadmin") returns all links
  • Link.visible_to("member") returns public + member links
  • Link.visible_to("anonymous") returns public links only
  • All existing links default to superadmin

Test Expectations

  • Unit test: visible_to scope returns correct links for each role
  • Unit test: validation rejects invalid visibility values
  • Run: bundle exec rails test

Constraints

  • String column, not Postgres enum (easier to extend, no ALTER TYPE needed)
  • Default must be superadmin (safe default per docs/visibility.md)

Checklist

  • PR opened
  • Tests pass
  • Migration runs cleanly on dev and prod
  • No unrelated changes
  • project-palinks — project page
  • docs/visibility.md — tier definitions
  • docs/auth.md — schema design
### Type Feature ### Lineage Follow-up from spikes #16 (`docs/auth.md`) and #17 (`docs/visibility.md`). ### Repo `ldraney/palinks` ### User Story As Lucas I want each link to have a visibility level So that I can control which audience sees which links ### Context The visibility system uses three tiers: public, member, superadmin. Default is `superadmin` (safe — new links are private until shared). This migration ships before auth is wired up — all existing links get `superadmin`, meaning no behavioral change until filtering is added in a separate ticket. ### File Targets - `db/migrate/xxx_add_visibility_to_links.rb` — new migration - `app/models/link.rb` — add VISIBILITY_LEVELS, VISIBILITY_HIERARCHY, visible_to scope, validation ### Feature Flag None — schema change with no visible behavior until filtering is wired up. ### Acceptance Criteria - [ ] Migration adds `visibility: string, default: "superadmin", null: false` - [ ] Check constraint limits values to `public`, `member`, `superadmin` - [ ] `Link.visible_to("superadmin")` returns all links - [ ] `Link.visible_to("member")` returns public + member links - [ ] `Link.visible_to("anonymous")` returns public links only - [ ] All existing links default to `superadmin` ### Test Expectations - [ ] Unit test: `visible_to` scope returns correct links for each role - [ ] Unit test: validation rejects invalid visibility values - Run: `bundle exec rails test` ### Constraints - String column, not Postgres enum (easier to extend, no ALTER TYPE needed) - Default must be `superadmin` (safe default per `docs/visibility.md`) ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] Migration runs cleanly on dev and prod - [ ] No unrelated changes ### Related - `project-palinks` — project page - `docs/visibility.md` — tier definitions - `docs/auth.md` — schema design
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/palinks#30
No description provided.