#Migrations
6 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
- Migrations - When to run migrations - Postgres
- Lexical Migration - Migrating lexical data from old version to new version
- Fields Overview - Field Types - Presentational Fields
- Fields Overview - Field Types - Virtual Fields
- Payload Concepts - Retrieving Data - Local API
Community-Help:
Bump
I've ran a verification through the migration too and it comes back correctly:
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