.dev/agent_docs/database_migrations.md
rails generate migration IssueNumberShortDescription
The generator template automatically includes the system_init_done guard
(return if !Setting.exists?(name: 'system_init_done')), which skips
data-migration logic on fresh installations where seeds handle setup.
Zammad migrations can include data migrations, not just schema changes.
Model.reset_column_information after adding/removing columns
in the same migrationWhen modifying table structure, also update the base migrations so fresh installations get the same schema (migrations are cumulative, but base files are the canonical schema source for new installs):
db/migrate/20120101000001_create_base.rbdb/migrate/20120101000010_create_ticket.rbConventions:
limit: 3 for timestamp precisiontype: :integer for polymorphic referencesid: :integer in create_table calls (Zammad uses integer primary keys, not bigint)New or updated settings must be added in both the migration and the seeds.
See existing examples in db/seeds/settings.rb for the correct structure.
Seeds live in db/seeds/ and use idempotent methods like
create_if_not_exists to avoid duplicates. When adding user-facing fields,
also update db/seeds/object_manager_attributes.rb.
MigrationHelper (lib/migration_helper.rb) provides utilities for
renaming custom object attributes and handling reserved SQL words.
rake db:migrate # Test the migration
rake db:rollback STEP=1 # Undo last migration (schema only — data migrations are not reversed)