Skip to content

CI4: Migrate migrations from CI3 to CI4 versions #3647

Closed

Description

@objecttothis

In CI3 the migrations table (ospos_migrations) was simple with a single column (version) and a single row which contained the last run migration. In CI4 the migrations table is more complex so we need a means of migrating the table, if one exists, from the CI3 version to CI4 without re-running migrations which have already run.

image

There are four scenarios that will be encountered on the OSPOS 3.4.0 install/upgrade

  • A clean install with no migrations table in the initial schema.
  • An existing install with OSPOS version 3.0.2 - 3.3.8 with a CI3 style migration table.
  • An existing install with OSPOS version 3.0.2 with no migration table.
  • An existing install with a pre-3.0.2 OSPOS version.

We only need to account for scenarios 1-3. In scenario 4 users will need to manually run scripts found in \app\Database\Migrations\sqlscripts\pre-3.0.2\ manually in order. The result will be that their database that is identical to scenario 3.

  • We need a migration table checker that checks to see if the CI3 migration table exists and if so, what version it's at. The function should return FALSE if the CI3 specific table doesn't exist (even if the CI4 table exists) or return the version number if it does exist.
  • If the CI3 migration table exists, we need to run a function that will convert it to CI4 and place the proper rows so that no migrations are re-run.
  • In the Login controller we need to modify its migrations version checker. It needs to probably call the CI3 table checker, call the CI3 migrations to CI4 migrations converter passing the version number received from the checker and then we need to update the version comparitor function that checks to see if there's an update. The current function works for CI3 but since there is more than one row in CI4, the current version always thinks there is a migration to be run. Instead it needs to ORDER BY version DESC and LIMIT 1 so that it shows the actual latest version run in the app.

Activity

  1. added this to the 3.4.0 milestone on Feb 4, 2023
  2. objecttothis commented on Feb 5, 2023

    @objecttothis
    MemberAuthor

    Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions