Blog: Visibility Migration
Mix.install([
{:jason, "~> 1.4"},
{:kino, "~> 0.9", override: true},
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"}
])
Navigation
Home Report An Issue Phoenix ComponentsOne-To-Many AssociationsBlog: Visibility Migration
Your existing Blog application should already have blog posts with a title
, subtitle
, and content
.
You’re going to make some modifications to the posts table that allow you to filter posts by visibility and sort them by a published date.
erDiagram
Post {
string title
text content
date published_on
boolean visibility
}
Requirements
-
Migration & Schema
-
Remove the
subtitle
field on posts -
Add a published_on
:date
field on posts. -
Add a
visible
:boolean
field with a default value oftrue
on posts. - (bonus) Add a unique constraint to post titles.
-
Remove the
-
Functionality
-
Update all post pages to account for the new and removed fields. For example, you will need to add the
visible
andpublished_on
fields to the post form and remove thesubtitle
field. - Display the list of posts from newest -> oldest.
-
Hide posts if
visible
isfalse
. -
(bonus) Hide posts if their
published_on
date is in the future.
-
Update all post pages to account for the new and removed fields. For example, you will need to add the
-
Tests
-
Write test(s) to ensure posts with
visible: false
are filtered from the list of posts. - Write test(s) to ensure posts are displayed from newest -> oldest.
- All tests should pass. You may need to modify old tests and pages to ensure they continue to pass.
- (bonus) Write test(s) to ensure posts with a published date in the future are filtered from the list of posts.
-
Write test(s) to ensure posts with
Commit Your Progress
DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.
Run git status
to ensure there are no undesirable changes.
Then run the following in your command line from the curriculum
folder to commit your progress.
$ git add .
$ git commit -m "finish Blog: Visibility Migration exercise"
$ git push
We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.
We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.