#Migrations

6 messages · Page 1 of 1 (latest)

fresh estuary
#

I've just ran a migration but the data isn't populated inside my collection, I can see it in my database though. Do I need to do something else within payload for it to read the data?

fresh estuary
#

Bump

#

I've ran a verification through the migration too and it comes back correctly:

fresh estuary
#

I rewrote the migration and it seems to be working, I can't quite figure out the blocks though

simple change: items is now called buttons, how can I do that in a block though?

import { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/db-mongodb'

export async function up({ payload, req, session }: MigrateUpArgs): Promise<void> {
  const collections = ['pages', 'regions', 'location-pages']
  for (const collectionName of collections) {
    const collection = payload.db.collections[collectionName].collection

    // Revert type back to listType
    await collection.updateMany(
      { 'layouts.blockType': 'imageButtons' },
      [
        {
          $set: {
            layouts: {
              $map: {
                input: '$layouts',
                in: {
                  $cond: {
                    if: { $eq: ['$$this.blockType', 'imageButtons'] },
                    then: {
                      $mergeObjects: [
                        '$$this',
                        {
                          buttons: '$$this.items',
                          items: '$$REMOVE',
                        },
                      ],
                    },
                    else: '$$this',
                  },
                },
              },
            },
          },
        },
      ],
      { session },
    )
  }
}
#

This does change the data but it isn't binded into the edit side