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

[5.6] RenameIndex support for migrations #24147

Merged
merged 3 commits into from
May 21, 2018

Conversation

slava-vishnyakov
Copy link
Contributor

@slava-vishnyakov slava-vishnyakov commented May 8, 2018

As described here: laravel/ideas#443 and as suggested by @tomschlick here, opening a PR for migration call to rename index (->renameIndex('from', 'to')).

Additionally tested on local installations of MySQL, Postgres, MS SQL - those support renaming indexes.

SQLite doesn't support renaming indexes (as is correctly pointed in laravel/ideas#443), so I'm using Doctrine and its getRenameIndexSQL, unfortunately it's protected, so basically, I've copied the implementation (this is from Doctrine's source):

protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)
{
    return [
        $this->getDropIndexSQL($oldIndexName, $tableName),
        $this->getCreateIndexSQL($index, $tableName)
    ];
}

So, for SQLite it's drop and re-create (and requires Doctrine), for others - it's native calls.

(Edit: wrong code snippet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants