2017 © Pedro Peláez
 

symfony-bundle custom-index-bundle

Annotation and command for control entity custom indexes

image

intaro/custom-index-bundle

Annotation and command for control entity custom indexes

  • Friday, December 1, 2017
  • by blackbjorn
  • Repository
  • 8 Watchers
  • 3 Stars
  • 21,467 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 12 Versions
  • 7 % Grown

The README.md

CustomIndexBundle

The CustomIndexBundle allows create index for doctrine entities using attribute with entity definition and console command., (*1)

Installation

CustomIndexBundle requires Symfony 5 or higher. Works only with PostgreSQL., (*2)

Run into your project directory:, (*3)

$ composer require intaro/custom-index-bundle

Register the bundle in config/bundles.php:, (*4)


<?php return [ ... Intaro\CustomIndexBundle\IntaroCustomIndexBundle::class => ['all' => true], ];

If your project have many schemas in single database and command must generate custom indexes only for one schema then add in your config.yml:, (*5)

intaro_custom_index:
    search_in_all_schemas: false
    allowed_index_types: ['gin', 'gist', 'btree', 'hash']

Default value of search_in_all_schemas is true. If you have different entities in different schemas and you need to update custom indexes in all schemas at once then you must set search_in_all_schemas to true or omit this config. If you have database with only public schema then search_in_all_schemas value doesn't matter., (*6)

Parameter allowed_index_types helps to exclude some types of indexes. If someone will try to use excluded type, command intaro:doctrine:index:update will return an error.
Default value is ['gin', 'gist', 'btree', 'hash']., (*7)

Usage

1) Add attributes in your entity, (*8)

<?php

namespace Acme\MyBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Intaro\CustomIndexBundle\Metadata\Attribute\CustomIndex;

#[ORM\Table(name:'my_entity')]
#[ORM\Entity]
#[CustomIndex(columns: ['my_property1'])]
#[CustomIndex(columns: ['lower(my_property1)', 'lower(my_property2)'])]
class MyEntity
{
    #[ORM\Column(type:'string', length: 256)]
    private $myProperty1;
    #[ORM\Column(type:'string', length: 256)]
    private $myProperty2;
}

Available CustomIndex properties:, (*9)

  • columns - array of the table columns
  • name - index name (default = 'i_cindex_<md5 hash from all CustomIndex attributes>').
  • unique - index is unique (default = false).
  • using - corresponds to USING directive in PostgreSQL CREATE INDEX command.
  • where - corresponds to WHERE directive in PostgreSQL CREATE INDEX command.

Required only columns property., (*10)

2) Use intaro:doctrine:index:update command for update db., (*11)

php app/console intaro:doctrine:index:update

You may use dump-sql parameter for dump sql with DROP/CREATE INDEX commands, (*12)

php app/console intaro:doctrine:index:update --dump-sql

Examples

Create index using pg_trgm extension:, (*13)

<?php

#[CustomIndex(columns: ['lower(my_column) gist_trgm_ops'], using: 'gist')]

Create unique index using PostgreSQL functions:, (*14)

<?php

#[CustomIndex(columns: ['lower(my_column1)', 'nullif(true, not my_column2 isnull)'], unique: true)]

Create partial index:, (*15)

<?php

#[CustomIndex(columns: ['site_id'], where: 'product_id IS NULL')]

The Versions

01/12 2017

dev-master

9999999-dev

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

11/10 2017

v0.2.4

0.2.4.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

06/06 2017

v0.2.3

0.2.3.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

10/03 2017

v0.2.2

0.2.2.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

08/03 2017

v0.2.1

0.2.1.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

02/03 2017

v0.2.0

0.2.0.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

02/03 2017

dev-schemas

dev-schemas

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

14/06 2015

v0.1.7

0.1.7.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

05/04 2015

v0.1.2

0.1.2.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

05/04 2015

v0.1.6

0.1.6.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

06/08 2014

v0.1.1

0.1.1.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index

09/06 2014

v0.1.0

0.1.0.0

Annotation and command for control entity custom indexes

  Sources   Download

MIT

The Requires

 

by Chernyavtsev Ivan

symfony2 index postgresql-index