Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add student progress migration #7049

Merged
merged 7 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/add-data-migrator
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add student progress migration
6 changes: 6 additions & 0 deletions includes/class-sensei.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Sensei\Internal\Student_Progress\Services\Lesson_Deleted_Handler;
use Sensei\Internal\Student_Progress\Services\Quiz_Deleted_Handler;
use Sensei\Internal\Student_Progress\Services\User_Deleted_Handler;
use Sensei\Internal\Student_Progress\Tools\Migration_Tool;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down Expand Up @@ -571,6 +572,11 @@
$this->lesson_progress_repository = ( new Lesson_Progress_Repository_Factory( $use_tables ) )->create();
$this->quiz_progress_repository = ( new Quiz_Progress_Repository_Factory( $use_tables ) )->create();

// Student progress migration.
if ( $use_tables ) {
( new Migration_Tool( \Sensei_Tools::instance() ) )->init();

Check warning on line 577 in includes/class-sensei.php

View check run for this annotation

Codecov / codecov/patch

includes/class-sensei.php#L576-L577

Added lines #L576 - L577 were not covered by tests
}

// Quiz submission repositories.
$this->quiz_submission_repository = ( new Submission_Repository_Factory( $use_tables ) )->create();
$this->quiz_answer_repository = ( new Answer_Repository_Factory( $use_tables ) )->create();
Expand Down
42 changes: 42 additions & 0 deletions includes/internal/installer/class-migration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* File containing the interface \Sensei\Internal\Installer\Migration.
*
* @package sensei
* @since $$next-version$$
*/

namespace Sensei\Internal\Installer;

/**
* Migration interface.
*
* @since $$next-version$$
*/
interface Migration {
/**
* The targeted plugin version.
*
* @since $$next-version$$
*
* @return string
*/
public function target_version(): string;

/**
* Run the migration.
*
* @since $$next-version$$
*
* @param bool $dry_run Whether to run the migration in dry-run mode.
*/
public function run( bool $dry_run = true );

/**
* Get the migration errors.
*
* @return array
*/
public function get_errors(): array;
}

Loading
Loading