ZodulaZodula
Cli

Migrate

Migrate

migrate

Apply database migrations to update your database schema.

Usage

nailgun migrate

Description

The migrate command applies all pending database migrations for special schema changes only. It runs migrations, applies fixtures, and handles predefined data. For general schema synchronization, use the sync command.

What It Does

  1. Starts up the Zodula server
  2. Applies all pending migrations (special schema changes only)
  3. Syncs database schema with current doctype definitions
  4. Applies fixtures (sample data)
  5. Applies predefined data

Migration Process

The migration process includes:

  • Special Schema Changes: Applies custom migrations for complex schema changes (for example, adding a new field to a doctype)
  • Data Migrations: Transforms existing data as needed
  • Fixtures: Applies sample/test data
  • Predefined Data: Sets up initial system data

When to Use

Run migrate when:

  • After creating custom migrations for special schema changes
  • After generating new migrations
  • When setting up a fresh database
  • After pulling changes that include migrations
  • When you need to apply fixtures and predefined data

Note: For regular doctype changes, the schema will be automatically synced. Use nailgun sync for manual schema synchronization.

Example

$ nailgun migrate

 Applying migrations...
 Applying fixtures...
 Applying predefined data...
 Syncing database schema...
 Migration completed successfully

Important Notes

  • Always backup your database before running migrations in production
  • Test migrations in a development environment first
  • Some migrations may be irreversible
  • The command will exit after completion

Troubleshooting

If migrations fail:

  1. Check the error messages in the terminal
  2. Ensure your database is accessible
  3. Verify migration files are valid
  4. Consider restoring from backup if needed

Tips

  • Run nailgun generate before migrate to create new migrations for special schema changes
  • Use nailgun sync for regular schema synchronization
  • Use nailgun backup before major migrations
  • Test migrations in development first
  • Keep your database backups up to date
  • Migrations are now only for special cases - regular doctype changes are handled automatically