conduit-full — data model

Four models, six associations, migrations as the only schema source of truth.

sequelize.sync({ alter: true }) ran at boot in the source app, silently patching the live schema to match whatever the models said — which is exactly how two missing foreign-key columns went unnoticed there. This repo's migrations were rewritten from scratch and are now the only thing that creates schema; boot just calls sequelize.authenticate(), a plain connectivity check with no side effects. See System Architecture for where these models sit.

Model Association Foreign key Through Worth knowing
User → Article hasMany, as author userId onDelete: CASCADE — deleting a user deletes their articles
User → Comment hasMany, as author userId No cascade set here — comments outlive a deleted author's other data
Article → Comment hasMany articleId onDelete: cascade — deleting an article deletes its comments
Article ↔ Tag belongsToMany, as tagList articleId / tagId TagList Response tagList is always re-derived from this join, never stored on the model
Article ↔ User belongsToMany, as favorites articleId / userId Favorites timestamps: false — a join table, not an entity with its own history
User ↔ User belongsToMany (self), as followers / following userId / followerId Followers Same through table, two aliases — one association per direction, not one bidirectional edge
!

Real bug, caught by a test: User's Comments association originally used the wrong foreign key — copy-pasted from the Article association above it and never corrected. A test written to fail on the original bug and pass on the fix caught it. Separately, the create-article/create-comment migrations never created the userId/articleId columns their models' associations need at all — invisible in the source because alter: true patched the live schema at boot, so the migrations were never actually exercised as the real schema source of truth. Every migration in this repo now cross-checks its column shape against the real model in its own test.