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

Migration interface #28

Open
dlh01 opened this issue Dec 20, 2024 · 0 comments
Open

Migration interface #28

dlh01 opened this issue Dec 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dlh01
Copy link
Member

dlh01 commented Dec 20, 2024

Description

We have used an interface like this on a few projects to moderate success:

/**
 * Describes a database alteration.
 */
interface Migration {
	/**
	 * Apply the migration.
	 *
	 * @phpstan-param array<int, string>    $args
	 * @phpstan-param array<string, string> $assoc_args
	 *
	 * @param array $args       Positional arguments.
	 * @param array $assoc_args Associative arguments.
	 */
	public function up( $args, $assoc_args = [] ): void;

	/**
	 * Reverse the migration.
	 *
	 * @phpstan-param array<int, string>    $args
	 * @phpstan-param array<string, string> $assoc_args
	 *
	 * @param array $args       Positional arguments.
	 * @param array $assoc_args Associative arguments.
	 */
	public function down( $args, $assoc_args = [] ): void;
}

However, the signatures are closely coupled to WP-CLi commands. There could perhaps be a decorator instead that adapts a migration object to a CLI command.

Use Case

Changing post meta in bulk, updating post terms in bulk, etc.

@dlh01 dlh01 added the enhancement New feature or request label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant