Running Decidim data migrations during upgrades

Decidim upgrades run schema migrations and data migrations as separate steps, and the data migrations are where custom modules most often break. This page explains how to check their status and write your own.

On this page

Why Decidim data migrations decide how smooth each upgrade step is

Data migrations decide how much of each Decidim upgrade step touches live participation data. When a team moves an install one minor version at a time, the question is what the data migrations will change in proposals, votes, participants and other records that people already rely on. The supported path answers it in three parts: upgrade one minor version at a time, follow the instructions for each release, and back up the database before you start. Decidim's updating guide states all three, and it explains that some releases change database structures, so skipping a step is not a shortcut.

The supported lines today are the 0.32.x and 0.31.x branches. Decidim supports only the last two minor versions with security updates until version 1.0, so 0.30.x and earlier no longer receive security fixes. An install on 0.29 or 0.30 therefore has to pass through 0.30 and 0.31 before it reaches 0.32, and each hop is a separate change to the database with its own data migrations to run and check. Confirm the current support window in the Decidim security policy before you plan dates, because the branch list can change between releases.

Before each step, decide who signs off on the backup and restore test, which environment rehearses the migrations, and how long participants can be kept off the platform if a migration runs slowly on a large dataset. Ask your provider or internal team to record the migration output and the row counts for key tables before and after each step, so a problem can be traced to one release rather than to the whole upgrade.

What each upgrade step changes and what it asks of your team

This table maps each release fact supplied for the 0.31 and 0.32 lines to its effect on data migrations, custom code and links. Read each row as a check to run before the upgrade, and confirm exact data migration commands and their output in each release's upgrade notes.

ChangeImpact on data migrationsImpact on custom code and linksAction needed
v0.32.0 released July 6, 2026Data migrations shipped with this release must be run in order after the schema migrations for the new code. Confirm the exact commands in its upgrade notes.Code written against the 0.31 APIs and views needs review before the upgrade starts.Read the 0.32.0 upgrade notes and list every data migration it adds.
Ruby on Rails 8.1 in v0.32.0Migration scripts that rely on Rails behavior from earlier versions may need adjusting. Test them on a copy of the database.Overrides and modules that call Rails internals may break. Run the custom test suite against 0.32.Rehearse the migration run on staging with a restored backup.
Locale-prefixed URLs in v0.32.0Data migrations that store or rewrite URLs, such as links in content, need a check for the new URL format.Hard-coded paths, custom redirects and links in emails or modules may point to old URLs.Search custom code and content for hard-coded paths and plan redirects.
Ruby 3.4.7 for v0.32Ruby version changes can alter how custom data migration code behaves. Verify your own migration tasks run on this version.Gems and modules must support Ruby 3.4.7 before the upgrade.Confirm Ruby 3.4.7 support for every community module and custom gem.
Ruby 3.3.4 for v0.31Teams moving through 0.31 must run its data migrations on Ruby 3.3.4 before continuing to 0.32.Custom modules must work on 3.3.4 as an intermediate step, not only on the final release.Plan each minor step as its own rehearsal and confirm the Ruby version at each stop.
Node 22.14.x for v0.31 and v0.32Asset builds run during the upgrade. Failed builds can block the steps that follow a data migration.Custom frontend code and asset pipelines need a build check on the same Node version.Confirm the Node version in the installation docs and test asset compilation on staging.
v0.31.7 released September 3, 2026 on the 0.31 branchPatch releases on the 0.31 branch may include fixes to data migration code. Check their notes before choosing a stop point.Patched code paths may change how overrides behave. Recheck any overrides touching the same classes.Apply the latest 0.31 patch before upgrading to 0.32 when your plan allows it.
v0.32.1 released July 30, 2026Follow-up fixes to 0.32.0 may change data migration behavior. Confirm whether any migration needs rerunning.Custom code tested against 0.32.0 should be retested against 0.32.1.Pin the exact patch version in your plan and retest after each patch.

How schema migrations and data migrations differ in Decidim

A schema migration changes the structure of the database: it adds or removes tables, columns and indexes. A data migration leaves the structure alone and transforms the records already stored, for example by backfilling a new column, rewriting a value into a new format or moving content between tables. Decidim's update guide warns that some releases change database structures, and that each release's upgrade instructions must be followed for that reason. Before you run anything, read the release notes for the version you are moving to and list which steps change structure, which change data and which do both. Treat the database backup as a precondition for either kind, since a data migration that goes wrong is often harder to reverse than a schema change.

A data migration can pass on an empty or lightly seeded test database and still fail on production. Test data rarely contains the edge cases that real participation platforms accumulate over years: unusual locales, long-running processes with many components, proposals with legacy field values, orphaned records left by deleted spaces, or custom content created by your own modules. A query that finishes in seconds on a few hundred rows can run for hours on production volumes, hold locks that block participants, or silently skip rows it does not expect. The practical check is to rehearse on a recent, production-sized copy of the database, then compare record counts and sample values before and after the run. Ask your team to confirm how long the rehearsal took and whether it touched every table your modules use.

What to prepare before running data migrations

Data migrations change records in place, so they are hard to reverse once they run. The four items below give you a way back, a clear picture of what can break, and a place to rehearse the upgrade before production. Work through them in order before you start the first minor version step.

Verified database backup

Take a full PostgreSQL backup before the first upgrade step, then confirm it restores. Decidim's update guide tells you to back up the database first, because data migrations rewrite records that a rollback to the previous code cannot undo. Restore the backup into a scratch database and run a few queries against proposals, users and component data to confirm it is complete. Record the Decidim version and the migration timestamp next to the backup so you know exactly which state it captures.

Decidim update guide

Inventory of custom modules

List every custom module, override and community module that reads or writes models, tables or records. Data migrations run against the schema and data your code expects, so any module that touches the same models can fail or corrupt data mid-run. Note the owner, the target version each module supports and whether its own migrations exist. This list becomes the input to your compatibility checks for each step.

Overrides that touch records

Review decorators, monkey patches and overridden classes that hook into model callbacks, scopes or save behavior. A patched method that changes how records are saved can make a data migration write unexpected values or skip steps. Mark each override as safe, needs rewriting or needs a test before the upgrade. Keep this review separate from view-only overrides, which are lower risk for data.

Staging copy with production data

Build a staging environment from a recent copy of production data, with the same PostgreSQL major version and the same file storage layout. Run each minor version step there first and time how long the data migrations take on your volume of proposals, comments and attachments. Use the timing to plan the maintenance window and to spot migrations that lock tables. Anonymize personal data in staging according to your own privacy rules before anyone outside the operations team uses it.

Upgrade and rollback owners

Name one person who approves each step, one who runs the migration commands and one who decides to roll back. Agree on the conditions for rollback, such as a failed data migration or a broken check on a key component, before the window opens. Write the contact list and the restore procedure in the runbook. Without named owners, a partial migration can sit in production while teams wait for a decision.

How to run data migrations one minor version at a time

This sequence moves a Decidim install through each minor release in turn, applying that release's schema and data migrations and confirming the result before the next step. Each pass ends with a known-good database and a clear rollback point, so a problem stays confined to one version.

  1. Back up the database and application state

    Before touching the code, take a full backup of the PostgreSQL database and the uploaded files held in ActiveStorage. Record the currently deployed Decidim version, the Ruby and Node versions, and the commit of any custom modules or overrides. The step is done when a restore of that backup has been tested on a separate host, because that restore is the rollback point for everything that follows.

  2. Read the upgrade notes for the next minor version

    Open the update instructions and release notes for the next minor version on the path, such as 0.29 to 0.30 before 0.31. Note the required Ruby and Node versions, any database structure changes, and any configuration keys that were added or renamed. The owner of the platform should sign off the list of changes that affect this install, so the team knows what to verify later.

  3. Deploy the target version to a staging copy

    Check out the target minor release in a staging environment built from a fresh copy of production data, with the same runtime versions the release requires. Re-apply your custom modules and overrides to that checkout. The step is complete when the application boots and the staging copy still serves the public site and admin panel, which confirms the code path before production is changed.

  4. Run schema and data migrations

    Run the database schema migrations and then the Decidim data migrations for the target version, following that release's instructions. Schema migrations change table structures, while data migrations rewrite or backfill records already in the database. Capture the command output and keep the log with the backup. The step is complete when the migration command exits without errors on staging and the record counts for affected tables match expectations.

  5. Check data migration status

    Use Decidim's data migration status command to list which data migrations have run and which remain pending for this environment. Confirm that every migration belonging to the target version is recorded as applied, and that no migration from an earlier version was skipped. If anything is pending or missing, stop and resolve it on staging, because a gap here will surface as hard-to-trace data errors later.

  6. Run application checks and test custom modules

    Run the application test suite, your custom module tests, and a smoke test of key flows such as login, creating a proposal, voting and the admin panel. Review any warnings about deprecated overrides or changed component settings. The step is complete when these checks pass on staging, and the results are recorded against the version you are moving to.

  7. Promote the version and record a rollback point

    Schedule the production change using the same steps that passed on staging, then take a fresh backup immediately before the migration runs. Record that backup as the rollback point for this minor version. The step is complete when production runs the target version, the status check matches staging, and the smoke tests pass against the live site.

  8. Repeat the sequence for each minor version

    Start the cycle again from the next minor version on the path, using the newly verified production state as the starting point. Do not skip a version even when the target is several releases away, since each release's data migrations assume the previous ones ran. The process ends when the install reaches the supported release line and the final status check shows all migrations applied.

How to check data migration status in each environment

The staging rehearsal is where you learn whether the data migrations behave on a copy of your real data. Run the upgrade on a restored copy of production, with the same custom modules, community modules and configuration that production uses. Confirm the result before you accept the rehearsal as a pass, because staging only helps if its checks are written down in advance.

  • Run count: Confirm each data migration for the release appears as applied exactly once, and that a second run does not change records again.
  • Record spot checks: Pick a sample of processes, proposals, users and components from before the upgrade and compare their titles, states, authors and dates with the expected values.
  • Background jobs: Confirm queued jobs drain to zero and no job failed with errors from your custom code.
  • Logs: Review application and worker logs for errors raised during the migration window, not only the final exit status.
  • Repeatable record: Save the list of checks and results so the production team runs the same list.

Finish by confirming that every check in the rehearsal list passed on a restore of the production backup, not on a fresh install.

Where schema and data migrations sit in each upgrade step

Each minor version step starts with a database backup, then the target version's code is deployed. Schema migrations run first and change database structure, followed by data migrations, which rewrite existing records. A status check confirms that every migration has completed before smoke tests run. If any check fails, the team restores the backup and stops, rather than moving on to the next minor version.

One minor version step, with the rollback path to the pre-upgrade backup.

How to add data migrations to your own Decidim module

When your own module needs to change stored data during an upgrade, write the change as a data migration that is idempotent, so running it twice leaves the database in the same state as running it once. Guard each step with a check for whether the change is already applied, for example by testing whether a column is populated or a record exists before writing it. Process large tables in batches, committing between them, so a long run does not hold locks on busy tables or exhaust memory on a single worker. Keep the logic free of references to application models, scopes and helper methods that the Decidim core or your own code may rename or change between minor versions. Where a migration needs model behavior, write the small query or update you need directly against the columns, so it still runs after those models change. Record in the migration's comments or a changelog entry which records it touched, why, and in which Decidim version you added it, so an operator reviewing a failed run can tell what was and was not changed.

Confirm the exact generator, base class and command for data migrations in your module's documentation and in the Decidim version you target, because these interfaces have changed between releases and the upgrade notes for each version are the authority on them. Once you have the generator, test each migration against a recent copy of production data in a staging environment built from the same backup you would restore from, not against a small seeded database. Check row counts before and after, confirm that a second run changes nothing, and time the run against a table of realistic size so you can plan the maintenance window. Keep your test copy's personal data handled under the same controls as production. For the broader sequence of upgrade steps and where data migrations fit, see the Decidim installation documentation and confirm the commands against the version you are running.

What makes data migration work take longer

This table compares five factors that change how much work a Decidim data migration run takes during an upgrade. Read each row as a direction: the right-hand columns show what pushes effort up and what keeps it down. The main takeaway is that the work scales with custom data changes, data volume and version gaps, so a clear inventory before the upgrade starts is the best way to estimate it.

FactorPushes effort upKeeps effort down
Custom modules that change recordsSeveral modules write or reshape participation data, so each data migration needs review, ordering and testing against that data.Few or no custom modules touch records, or their changes are limited to additive fields that existing data does not depend on.
Volume of participation dataLarge numbers of proposals, votes and comments make each run slower and make failures costlier to recover from.A smaller dataset or a recent archive of older content keeps run times short and rollback simpler to rehearse.
Minor versions between current and targetEach skipped step adds its own data migrations, upgrade instructions and checks, so the chain grows with every version crossed.A current install that is one or two minor versions behind has fewer migrations to order and verify.
Community modules without a target-version releaseA module that has not been updated may break during the data migration run or leave records in a state the new release does not expect.Every community module has a release for the target version, or the team has already decided on a replacement or removal.
Production-like staging environmentWithout a staging copy of production data, problems appear only in production, and reruns after fixes take longer to plan.A staging environment with a recent copy of the database, the same modules and similar configuration lets the team rehearse each run and time it.

Questions teams ask before running Decidim data migrations

How much does a Decidim data migration upgrade cost?

No public price applies to this work, and DeployOpen does not publish a price list, so the cost comes from a written scope. The main cost is skilled engineering time for the upgrade itself, covering the release notes review, staging rehearsal, running each data migration, checking results and fixing custom code that breaks. Costs rise with the number of minor versions you must cross, since Decidim's update guide asks you to move one minor version at a time, for example 0.29 to 0.30 before 0.31. Costs also rise with the number of custom modules, overrides and community modules that need changes. Ask for the quote to separate the one-time upgrade work from any recurring retainer for support or security patching, and ask which environments (staging, production, backups) are included.

How long does a Decidim data migration take?

Duration depends mainly on the size and condition of your data, the number of minor versions you cross, and how much custom code you run. Data migrations run against your database, so a large database with many proposals, participants or attachments takes longer to process than a small one, and a staging rehearsal on a production-sized copy is the best way to measure it. Each step in the upgrade chain adds its own migration run, testing and fix cycle. Custom modules and overrides add review time because each one must be checked against the target release. Ask for a written timeline that names the staging rehearsal, the production window and the rollback point, rather than a single overall number.

What does our team need to provide for a Decidim data migration?

The work needs access to a current database backup process, a staging environment that matches production as closely as possible, and the deployment configuration for background jobs, file storage and mail. Your team should provide the list of custom modules, overrides and community modules in use, along with their owners, so the upgrade can be checked against each one. You also need a named person who can approve the production window and confirm business acceptance after testing. Decidim's update documentation says to back up the database before upgrading, so confirm that backups are tested and restorable. Ask the provider to list these inputs in the written scope so gaps are found before work starts.

Can our internal team run a Decidim data migration without a partner?

Yes, an internal team can run a Decidim data migration if it has Rails and PostgreSQL experience, can rehearse the upgrade in staging, and has time to read each release's upgrade instructions. Decidim's update guide says to follow each release's instructions because some change database structures, so the team must track every step in the chain. The harder parts are usually the custom code: overrides, monkey patches and community modules that may not support the target version. Teams with few engineers, no staging copy, or a long chain of versions often choose a partner for the planning and rehearsal. Compare the internal estimate with a written partner scope before deciding, and be clear about who owns the production rollback.

What happens if a Decidim data migration fails halfway through?

A failed data migration leaves the database in an uncertain state, so the first step is to stop, avoid further changes, and restore from the backup taken before the upgrade. Decidim's update guide asks for a database backup before each upgrade for this reason. The restore plan should be rehearsed in staging, with a clear point where the team decides to roll back rather than push forward. Check the migration log to find which step failed, then fix the cause in staging before trying again in production. Ask the provider how failed runs, restores and retests are handled in the written scope, and whether a retest is included after a fix.

How do we check a Decidim data migration status before going live?

Check the status by running the migration task on a staging copy and reviewing its output, then confirm that the expected database changes are present. Compare record counts and key data for proposals, participants and components against the pre-upgrade backup. Test the main public and admin paths, including login, participation flows and any custom modules, because a migration can succeed while custom code still fails. Keep a written checklist of these checks so the same evidence is available for each minor version in the chain. Ask the provider which checks are included in the scope and what evidence you will receive at handover.

Are there security risks in running Decidim upgrades late?

Yes, staying on an unsupported release creates security exposure, because Decidim supports only the last two minor versions with security updates until version 1.0. Decidim's security policy gives implementers a grace period of 2 months for standard vulnerabilities and 4 months for critical ones before details are disclosed, so delayed upgrades reduce the time you have to apply patches. Confirm your current version against the supported branches and plan the upgrade chain early. Ask the provider how security patches are handled during the upgrade and whether ongoing support is offered after go-live.

How DeployOpen scopes a Decidim upgrade with data migrations

DeployOpen starts a data migration scope with an inventory of everything that touches the database or the Rails application. That means the installed Decidim version, the Ruby and Node runtimes, every community module and local override, custom data migrations already written by the client's developers, and any scheduled tasks that read or rewrite records. For each item we record the owner, whether it is maintained, and whether it declares support for the target minor version. Pending data migrations are listed separately so the client can see which ones the upcoming step will run and which ones were already applied on the current release. The output is a written inventory that the client approves before any work is quoted or started.

Each minor-version step is then rehearsed on a staging copy built from a recent production backup, with the same database engine, background job setup and file storage as production. The rehearsal runs the update instructions for that release in order, records the data migrations executed and their duration, and checks the admin panel, public spaces and custom components against a written list of test cases. Results are compared with the previous rehearsal so that slow or failing migrations are found before the production window. Before each production window, DeployOpen documents a rollback point: a verified database backup taken immediately beforehand, the code revision and configuration that match it, and the conditions under which the team would stop and restore. The client confirms who makes the go or no-go decision and who has authority to restore.

How DeployOpen works on this

DeployOpen plans, builds, tests, documents and supports Decidim upgrades inside your own infrastructure, so data migrations are reviewed and rehearsed before they touch production. Each engagement starts with a written scope that covers the data migration work for your installation, your custom code and your community modules.

How we scope

  • Inventory your installed Decidim version, database state and every migration that has not yet run on your instance.
  • Identify custom modules, overrides and community modules that add or change data migrations and need review.
  • Agree deliverables, timelines and responsibilities in writing before work starts, since most engagements are fixed-scope.

How we build

  • Work through each minor version step in the order the upgrade documentation sets, with a database backup taken before each step.
  • Write or adjust data migrations for your own modules and test them against a copy of your production data.
  • Run the application's data migration status checks at each step and record results before moving to the next version.

How we hand over

  • Deliver the upgrade runbook, the data migration log and the rollback steps for each version you move through.
  • Document changes to custom modules, including any new data migration files and how to run them in your environment.
  • Walk your platform and operations team through the runbook and confirm they can repeat the steps on their own.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after the initial upgrade is complete.
  • Review each new Decidim release against your custom code and community modules before you schedule the next step.
  • Confirm with your own team which release line and support window applies to your installation before planning further upgrades.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.