2. Comments, and posts that belong to nobody · Your task

Your task

All of this goes in one new tab, 003_comments.sql.

1. Fix the bug. Make posts.user_id a real foreign key to users. Inkwell's rule: when a user deletes their account, their posts go with them.

2. Create comments.

Column Type Notes
id serial primary key
post_id integer the post being commented on
user_id integer who wrote the comment
body text
created_at timestamp

Rules: a comment can't exist without its post, and it can't exist without its author. If either is deleted, the comment goes too.

3. Check your tabs are saved. The workbench writes every tab to data/migrations/sql/ (the header says Saved to …).