Give routes a surrogate primary key #170
Labels
No labels
bug
devops
duplicate
enhancement
good first issue
layout
next major release
next minor release
question
research
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
#155 Title rewriting rules per feed and route}
lvl0/fedi-feed-router
#169 Run the test suite against MariaDB instead of SQLite
lvl0/fedi-feed-router
Reference: lvl0/fedi-feed-router#170
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
routeshas a composite primary key(feed_id, platform_channel_id)and noid.app/Models/Route.php:29setsprotected $primaryKey = nullwith$incrementing = false, and the comment concedes "Laravel doesn't handle composite primary keys well, so we'll use regular queries."No polymorphic relation can target a route, which blocks the title rules in #155.
Scope — smaller than it appears
Investigated before filing:
where('feed_id', …)->where('platform_channel_id', …). Nothing usesfind(), a route id, or route model binding. Addingidis additive — no call site changes.route_articles' composite FK references(feed_id, platform_channel_id), which stays as a unique constraint. Noroute_idcolumn, no backfill, no FK swap.keywordsFKs tofeedsandplatform_channelsdirectly, not toroutes. Unaffected.RouteArticle::route()(app/Models/RouteArticle.php:56) is broken and dead. The relation is defined as:$this->platform_channel_idis evaluated when the relation is defined, not when the query runs, so it would misbehave under eager loading. Nothing calls it and no test covers it. Fix or delete.The one real risk
Converting a composite PRIMARY KEY to a UNIQUE while adding an AUTO_INCREMENT
id, with a foreign key depending on that index. MariaDB may refuse to drop the primary key whileroute_articlesreferences those columns, forcing a drop-alter-re-add of the FK.This is unverified — the dev database was unreachable when this ticket was written (see #169). It is why this ticket is sequenced after #169: on SQLite the migration would pass regardless of whether it works on MariaDB.
Acceptance criteria
routes.idexists and auto-increments;(feed_id, platform_channel_id)remains uniqueRouteno longer sets$primaryKey = null/$incrementing = falseRouteArticle::route()relation resolvedFixBelgaFeedOffsetMigrationTestdoes for #158Related