I am building a site, and among other things, I need to allow a user to create their custom landing page.
Each user will upload their own header image, create a custom title, description, and other content.
Currently, I have a table that holds all the page elements. But I want to enable users to have a draft version of the page while a published version might already exist. And while they are editing their page, I want to allow the users to preview their work (for example, clicking a "preview" button while editing).
What is the best way to achieve the above in terms of database tables?
For example, the main table containing the elements of the saved finalized and published page is something like the following:
user_id: Integer - foreign key to the user table header_image: Varchar - contains the name of the image, save on S3 title: Varchar - the title of the page description: Text - some page content
At the moment, I think that to have a preview mode, which is a non-published page, I could have another table, identical to the
user_page table called for example
So while the users are editing their page, I save all in
preview_user_page. And when they click the preview button, I show the page with the content stored in the
When the users are ready and press the publish button, I copy their content into the
user_page table, providing the data for the posted finalized page.
Is there a better way?