Skip to content

Rename column in migration has no effect #2391

Closed
@flappix

Description

@flappix
  • Laravel-mongodb Version: 3.8
  • PHP Version: 8.1.16
  • Database Driver & Version: MongoDB 4.4.14, mongodb php driver 1.13.0

Description:

When I try to rename a field of a collection within a migration using $table->renameColumn() the migration runs without errors but the fields in the collection have the same name as before running the migration

Steps to reproduce

Collection users:

{
    _id: 62859365a1767a00c9589712,
    name: "admin",
    role: "member"
}

Migration file:

class RenameUser extends Migration
{
    public function up()
    {
		Schema::table ('users', function (Blueprint $table) {
			$table->renameColumn ('role', 'global_role');
		});
    }
}

> php artisan migrate

Expected behaviour

I expected the same behavior as running the following monogdb command
db.users.updateMany ({},{ $rename: { 'role': 'global_role'}} )
The name of the field role should be global_role after running the migration.

Actual behaviour

Nothing, no error but also no effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions