Drafts and publishing workflows

Drafts and other publishing workflows are essential for a great CMS experience. Instead of force-feeding you a complex workflow builder, Flashboard relies on your database design for drafts and content workflows.

We recommend using PostgreSQL Enum types for status fields. You can design them to be a perfect fit for your business logic, but for example, you can have an enum type with draft and published options and use it in your content table. Then, Flashboard will show you a dropdown menu:

Table with "State" column with a dropdown to choose between "Draft" and "Published"

(Optional) Validations and rules

If you want to ensure your content is only published when it is valid, we recommend using PostgreSQL Triggers. Your triggers can validate your data and show a custom error message for each situation. For example, here's a trigger that checks if all necessary fields are not null before publishing:

CREATE OR REPLACE FUNCTION ensure_published_blog_post_has_required_fields()
RETURNS TRIGGER AS $$
BEGIN
  IF NEW.state = 'published' AND (
    NEW.title IS NULL OR
    NEW.description IS NULL OR
    NEW.content IS NULL
  ) THEN
    RAISE EXCEPTION 'Please fill all fields before publishing.';
  END IF;
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER ensure_published_blog_post_has_required_fields_trigger
BEFORE INSERT OR UPDATE ON blog_posts
FOR EACH ROW
EXECUTE FUNCTION ensure_published_blog_post_has_required_fields();

Then, users will see the message on Flashboard when the trigger goes off:

Felipe Freitag, Flashboard founder

Need help?

Hey! I'm Felipe, Flashboard's founder. I'll personally help you and make sure you get your panel up and running.