Skip to main content

migrate_append

Function migrate_append 

Source
pub fn migrate_append(
    account: &AccountView,
    payer: &AccountView,
    program_id: &Address,
    old_layout_id: &[u8; 8],
    new_version: u8,
    new_layout_id: &[u8; 8],
    new_disc: u8,
    new_size: usize,
) -> ProgramResult
Expand description

Migrate an account in-place by appending new fields.

This is the cheapest migration: no data movement, just realloc + header update.

§Preconditions

  • Account must be owned by program_id
  • Account must be writable
  • Account layout_id must match old_layout_id
  • new_size > old_size (append-only growth)

§What it does

  1. Validates ownership, writable, and old layout_id
  2. Reallocs account data to new_size
  3. Updates header: new version, new layout_id
  4. Zeroes the newly appended region

New fields are left zero-initialized. The caller should fill them after.