Course Overview
Locked video preview

Paid video

Please purchase the course to watch.

Building the home view

Second migration: only show published articles

Here is a summary of the video transcript:

  • Adding a Publication State to Articles
    A new published_at column is introduced to distinguish between draft and published articles. This enables iterative editing before public visibility.

  • Database Migration Strategy
    A migration file is created to modify the database schema without directly altering the table. The migration adds a nullable timestamp column and includes a corresponding down migration to remove it if needed.

  • Using Timestamps for Publishing
    The published_at column stores a timestamp with timezone to indicate when an article is published. This supports chronological ordering and improves content freshness visibility for users and search engines.

  • Updating Queries
    A new query retrieves only published articles by filtering where published_at is not null and ordering results in descending order. The insert query is also updated to include the new column.

  • Modifying the Data Model
    The article model struct is extended to include the published_at field. Supporting helper methods and find functions are updated to accommodate this new attribute.

  • Implementing Published Article Retrieval
    A dedicated function is added to fetch only published articles. The home controller is updated to use this function so that only published content appears on the homepage.

  • Handling Article Creation Logic
    The create function now accepts a boolean flag to determine publication status. If published is true, the current timestamp is assigned; otherwise, the field remains null.