Mass changing post visibility - mysql

I have lots of posts for “paid-members” only. What query to use in mysql ssh “find and replace” to change visibility of posts from paid-members to public?

It’s suggested that you use the Ghost API rather than directly modify the database since the API will prevent you from breaking things :slight_smile: I think you need to update the visibility field to public

Hi,I never worked that way. How to use it? configuration file, ghost cli?

You’ll need to create a custom integration so you can get an Admin API key:

From there, you’ll need to write a script (nodejs is suggested since there is the @tryghost/admin-api package that does a lot of the heavy lifting for you) like this:

(haven’t tested but do something like this):

const GhostAdminAPI = require('@tryghost/admin-api');
const api = new GhostAdminAPI({
    url: 'http://localhost:2368',
    version: "v3",
// 1. Get a list of posts which need to be updated (we only need the post id)
const postsToConvert = await api.posts.browse({
  filter: 'visibility:paid',
  fields: 'id'
// 2. Update the posts
for (const post of postsToConvert) {
  // This updates posts 1 by 1. If you need to go faster, you can parallelize this
  await api.posts.edit({id:, visibility: 'public'});