Flyway Migrations

Firmiana uses Flyway for versioned schema management. There are 23 migrations (V1–V23).

Migration History

VersionNamePhaseDescription
V1baseline_schemaP0Core tables: users, rooms, events, tokens, devices
V2three_pid_validationP0Third-party ID validation table
V3typing_streamP0Typing indicator stream
V4receipt_streamP0Read receipt stream
V5device_inboxP0To-device message inbox
V6presence_streamP0User presence status stream
V7device_list_streamP0Device list change notifications
V8user_profileP0User profile data
V9media_metadataP0Media upload metadata
V10user_pusherP0Push notification gateway config
V11event_dag_minimalP0Event DAG relationships
V12forward_extremityP0Forward extremity tracking
V13state_group_and_auth_chainP0State resolution groups
V14p1_e2ee_pushP1E2EE and push notification tables
V15media_quarantineP1Media quarantine status
V16notification_tableP1Notification delivery tracking
V17media_thumbnailsP1Thumbnail cache storage
V18media_url_preview_cacheP1URL preview cache
V19server_signing_keyP2Federation signing key storage
V20appservice_registrationP2Application service registrations
V21p3_index_additionsP3Composite indexes for performance
V22event_search_fulltextP3Event search content index
V23space_and_relationsP4Space support, event relations

Migration Naming

Migrations follow the Flyway convention: V{version}__{description}.sql

Double underscore (__) separates the version from the description.

Adding New Migrations

Create a new SQL file in src/main/resources/db/migration/:

V24__description.sql

The file should contain only DDL statements (CREATE TABLE, ALTER TABLE, CREATE INDEX).

Warning

Never modify existing migration files. If you need to change the schema, create a new migration.

Baseline Migration

The baseline schema (V1) creates the core tables:

  • users, user_passwords, user_access_tokens, user_refresh_tokens
  • rooms, room_user, room_aliases
  • event, event_relations
  • forward_extremity, room_state_group
  • device_inbox, device_list_stream
  • typing_user, presence_stream, receipt, room_receipt
  • media_metadata, media_auth_token
  • user_push_rules, user_pushers
  • notification, event_push_summary

Database Reset

To reset the database:

rm -rf data/matrix*
mvn exec:java

Flyway will re-run all migrations from scratch.