Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Christian Tricarico 12 posts 92 karma points c-trib
    Apr 24, 2020 @ 09:29
    Christian Tricarico
    0

    Custom database migration not applied

    Hi Devs, I developed a new feature in an Umbraco v7 website where a new custom table is needed. In order to automatically update the database schema I developed a new custom migration (not the first time for me with migrations). The migration is executed correctly in development and staging environments but not in production. After the deploy I see the new record in the umbracoMigration database table but the new table is not created. In the log I find:

    2020-04-24 07:33:07,186 [P580/D4/T107] INFO Umbraco.Core.Persistence.Migrations.MigrationRunner - Initializing database migrations 2020-04-24 07:33:07,186 [P580/D4/T107] INFO Umbraco.Core.PluginManager - Resolving umbraco.interfaces.IDiscoverable 2020-04-24 07:33:07,186 [P580/D4/T107] INFO Umbraco.Core.PluginManager - Resolved umbraco.interfaces.IDiscoverable (took 0ms) 2020-04-24 07:33:07,186 [P580/D4/T107] INFO Umbraco.Core.PluginManager - Resolving Umbraco.Core.Persistence.Migrations.IMigration 2020-04-24 07:33:07,186 [P580/D4/T107] INFO Umbraco.Core.PluginManager - Resolved Umbraco.Core.Persistence.Migrations.IMigration (took 1ms)

    It seems the SQL execution part is missing. It looks like the new migration class (the one that implements IMigration) is not recognized.

    I'm quite sure it's a caching issue ... after the deploy the web.config is not changed ad the app wasn't restarted.

    Indeed if I remove the new row in umbracoMigration table, change the web.config and refresh the log contains:

    2020-04-24 09:24:20,238 [P580/D9/T25] INFO Umbraco.Core.Persistence.Migrations.MigrationRunner - Initializing database migrations 2020-04-24 09:24:20,238 [P580/D9/T25] INFO Umbraco.Core.PluginManager - Resolving umbraco.interfaces.IDiscoverable 2020-04-24 09:24:20,238 [P580/D9/T25] INFO Umbraco.Core.PluginManager - Resolved umbraco.interfaces.IDiscoverable (took 0ms) 2020-04-24 09:24:20,238 [P580/D9/T25] INFO Umbraco.Core.PluginManager - Resolving Umbraco.Core.Persistence.Migrations.IMigration 2020-04-24 09:24:20,238 [P580/D9/T25] INFO Umbraco.Core.PluginManager - Resolved Umbraco.Core.Persistence.Migrations.IMigration (took 1ms) 2020-04-24 09:24:20,363 [P580/D9/T25] INFO Umbraco.Core.Persistence.Database - Table 'PageViews' already exists - no changes were made 2020-04-24 09:24:20,363 [P580/D9/T25] INFO Umbraco.Core.Persistence.Migrations.MigrationRunner - Added UPGRADE migration 'CreatePageViewsTable' to context

    Note: it says PageViews already exists because I created it manually before. The point is that now it tried to run the migration.

    So the question is: is there a way to avoid this issue happens? Force a web.config change at every deploy is the only solution or is there a better approach?

    Thanks in advance, Christian

Please Sign in or register to post replies

Write your reply to:

Draft