indexes for mysql schema dump#1
Conversation
|
Sounds like a great addition! Let me take a look at it. |
| const PHINX_TYPE_CHAR = 'char'; | ||
| const PHINX_TYPE_TEXT = 'text'; | ||
| const PHINX_TYPE_INTEGER = 'integer'; | ||
| const PHINX_TYPE_DOUBLE = 'double'; |
There was a problem hiding this comment.
I think this would be better in a separate PR.
| case static::PHINX_TYPE_FLOAT: | ||
| return array('name' => 'float'); | ||
| break; | ||
| case static::PHINX_TYPE_DOUBLE: |
There was a problem hiding this comment.
I think this would be better in a separate PR.
| * @return array | ||
| */ | ||
| protected function getIndexes($tableName) | ||
| public function getIndexes($tableName, $lowercase = true) |
There was a problem hiding this comment.
What's the added benefit of lowercase?
There was a problem hiding this comment.
this method was originally lowercasing all index column names (as it is currently). I initially thought I needed to have case sensitive column names for mysql on some operating systems. That turned out to be incorrect thinking on my part. I have removed the extra param
-fix some primary key issues which were cropping up on tables where a column name was id but was not the pk
-remove lowercase param from index function, indexes are not case sensitive in mysql -account for tables that do not have primary keys when dumping a schema
|
I removed the DOUBLE column type and fixed the commit history to remove the superfluous commit. I also noticed another issue that needed to be addressed for tables that do not have primary keys, that has been fixed in the most recent commit. |
|
Looks good to me, thanks! |
|
I made a few improvements to the code:
Other than that, it works great :-) |
| <?php endforeach; ?> | ||
|
|
||
| <?php foreach($table->getIndexes() as $name => $index): ?> | ||
| <? if ($name !== 'PRIMARY'): ?> |
|
@jwh315 I have fixed some more:
|
* Add index capability to the schema:dump feature * Set index limits where applicable. Fix some primary key issues which were cropping up on tables where a column name was id but was not the pk. * Account for tables that do not have primary keys when dumping a schema
I ran across your schema dump/load feature for phinx a few weeks ago. I really love your implementation but really needed indexes. I was able to get the indexes put into the mysql adapter pretty easily.
I have a pretty decent size dev database (over 700 tables) at my company, that has an array of ridiculous design inconsistencies from years of development. The indexing seems to be recreating tables 100% from their original state, so I am fairly confident that I have covered most edge cases related to indexing and phinx.
Not sure if you would be interested in merging this branch into yours, or if you would need more from my end before doing so.
Either way, thanks for the effort putting this schema dumper together, it has saved me several hours worth of work.