Add ability to set index names
This PR allows setting the index name.
While testing dropping by the same name I discovered that dropKey() was generating errors when dropping a unique index be several of the DBMS. The reason is that some DBMS require DROP CONSTRAINT command rather than DROP INDEX. I did some extra work to get dropKey() to work properly.
MySql and SQLite don't really require a name for Primary Key - though Mysql allows setting the name. When dropping its as simple as DROP PRIMARY KEY.
Checklist:
- [x] Securely signed commits
- [x] Component(s) with PHPDoc blocks, only if necessary or adds value
- [x] Unit testing, with >80% coverage
- [x] User guide updated
- [x] Conforms to style guide
While testing dropping by the same name I discovered that dropKey() was generating errors when dropping a unique index be several of the DBMS. The reason is that some DBMS require DROP CONSTRAINT command rather than DROP INDEX. I did some extra work to get dropKey() to work properly.
This is a bug fix. If you don't send a PR to fix it, at lease please add it in the changelog.
@phpstan-var array|array{fields: string[], keyName: string}
Please rebase to resolve the conflict.
I think I accidently merged with 4.3 rather than rebase.
What should I do? It looks like it should be fine as all the commits it added here have already been merged.
I can git interactive rebase and try and remove the extra commits.. any suggestions?
I tried git reset --merge adf1e32 and I think I made it worse.
Probably going to have to start all over and submit a new PR.
I think I accidently merged with 4.3 rather than rebase. What should I do?
Just do git rebase again.
It looks like it should be fine as all the commits it added here have already been merged.
Yes, of course it is fine. Just the commit log history is not clean.
I tried git reset --merge https://github.com/codeigniter4/CodeIgniter4/commit/adf1e32b96a74f77121a2e3d1672a6b1455d6463 and I think I made it worse.
This branch has been messed up. It seems no longer usable. You can only extract the commits you need from this branch.
Run git rebase -i and drop unneeded commits?
I pushed my local this PR branch: https://github.com/kenjis/CodeIgniter4/commits/SetManualIndexNames
I'm on vacation until Monday and might not be able to get this sorted out until then..
Run git rebase -i and drop unneeded commits?
Ya, this was my next attempt. It might take some time to sort out my commits from other PRs though.
I think I have it straightened out now.
Not the fault of this PR, but there are PHPStan errors. Please rebase.
Error: Result of && is always false.
Error: Strict comparison using !== between 0 and 0 will always evaluate to false.
------ ---------------------------------------------------------------------
Line system/Helpers/array_helper.php
------ ---------------------------------------------------------------------
51 Result of && is always false.
51 Strict comparison using !== between 0 and 0 will always evaluate to
false.
------ ---------------------------------------------------------------------
@codeigniter4/database-team I'm merging this for now. If you find something wrong, please comment.
@sclubricants Thank you!
🏆