2017 © Pedro Peláez
 

library force-named-indexes

Dbmover plugin to force the use of named indexes

image

dbmover/force-named-indexes

Dbmover plugin to force the use of named indexes

  • Saturday, April 15, 2017
  • by monomelodies
  • Repository
  • 1 Watchers
  • 0 Stars
  • 66 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 16 % Grown

The README.md

Dbmover\ForceNamedIndexes

Plugin for DbMover that rewrites SQL to always have named indexes., (*1)

Some vendors like MySQL already require named indexes (at least, when defined using CREATE INDEX), with others (like PostgreSQL) the names are optional., (*2)

Using named indexes helps DbMover compare existing indexes and aids in avoiding unnessecary index recration and thus longer migrations., (*3)

Indexes already explicitly named in your schemas remain untouched, so you'll only need this plugin if you're lazy ;), (*4)

Installation

composer require dbmover/force-named-indexes

Usage

For general DbMover usage, see dbmover/core., (*5)

You'll typically want to load this plugin before the VENDOR-indexes plugin., (*6)

Workings

The plugin rewrites your SQL so each unnamed index will get an explicit name of the form TABLE_FIELD1_FIELD2_FIELDN_idx. For complex index definitions like possible in e.g. PostgreSQL, it also strips all non-word characters (technically, replace "\W+" with "_")., (*7)

Caveats and gotchas

  • Vendors may impose limits on index name lengths and silently truncate overly long names. In these cases, obviously, DbMover will see them as different indexes. The solution is to explicitly name these indexes.
  • Some vendors (e.g. PostgreSQL) allow indexes with a WHERE clause. If the used fields are the same as another index, DbMover will only see the last one defined (after all, the implicit names will be the same). Again, the solution is to explicitly name these indexes (e.g. users_male and users_female for indexes on users(gender) where gender = 'm' and gender='f').

Again, it's always better to explicitly name indexes just in case. But programmers are lazy..., (*8)

Note that you can use this plugin in combination with dbmover/mysql to avoid having to explicitly name all your indexes - it does produce a lot of boilerplate., (*9)

Contributing

See dbmover/core., (*10)

The Versions

15/04 2017

dev-master

9999999-dev

Dbmover plugin to force the use of named indexes

  Sources   Download

MIT

The Requires

 

by Marijn Ophorst

15/04 2017

0.1.1

0.1.1.0

Dbmover plugin to force the use of named indexes

  Sources   Download

MIT

The Requires

 

by Marijn Ophorst

15/04 2017

0.1.0

0.1.0.0

Dbmover plugin to force the use of named indexes

  Sources   Download

MIT

The Requires

 

by Marijn Ophorst