{"id":18903598,"url":"https://github.com/intaro/custom-index-bundle","last_synced_at":"2025-08-22T05:32:17.356Z","repository":{"id":17760327,"uuid":"20616593","full_name":"intaro/custom-index-bundle","owner":"intaro","description":"The bundle allows to describe and create non-standard database indexes for entities","archived":false,"fork":false,"pushed_at":"2022-07-05T12:03:17.000Z","size":39,"stargazers_count":25,"open_issues_count":1,"forks_count":16,"subscribers_count":15,"default_branch":"master","last_synced_at":"2023-12-19T15:02:22.026Z","etag":null,"topics":["bundle","php","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/intaro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-08T12:51:41.000Z","updated_at":"2023-02-27T16:20:11.000Z","dependencies_parsed_at":"2022-07-26T19:30:08.428Z","dependency_job_id":null,"html_url":"https://github.com/intaro/custom-index-bundle","commit_stats":null,"previous_names":[],"tags_count":24,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fcustom-index-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fcustom-index-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fcustom-index-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fcustom-index-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intaro","download_url":"https://codeload.github.com/intaro/custom-index-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230091680,"owners_count":18171547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","php","symfony","symfony-bundle"],"created_at":"2024-11-08T09:05:52.371Z","updated_at":"2024-12-20T09:07:24.403Z","avatar_url":"https://github.com/intaro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CustomIndexBundle\n\nThe CustomIndexBundle allows create index for doctrine entities using attribute with entity definition and console command.\n\n## Installation\n\nCustomIndexBundle requires Symfony 5 or higher. Works only with PostgreSQL.\n\nRun into your project directory:\n```\n$ composer require intaro/custom-index-bundle\n```\n\nRegister the bundle in `config/bundles.php`:\n\n```php\n\n\u003c?php\n\nreturn [\n   ...\n    Intaro\\CustomIndexBundle\\IntaroCustomIndexBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\nIf your project have many schemas in single database and command must generate custom indexes only for one schema then add in your `config.yml`:\n\n```yaml\nintaro_custom_index:\n    search_in_all_schemas: false\n    allowed_index_types: ['gin', 'gist', 'btree', 'hash']\n\n```\n\nDefault value of `search_in_all_schemas` is `true`.\nIf 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.\nIf you have database with only public schema then `search_in_all_schemas` value doesn't matter.\n\nParameter `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.  \nDefault value is `['gin', 'gist', 'btree', 'hash']`.\n\n## Usage\n\n1) Add attributes in your entity\n\n```php\n\u003c?php\n\nnamespace Acme\\MyBundle\\Entity;\n\nuse Doctrine\\ORM\\Mapping as ORM;\nuse Intaro\\CustomIndexBundle\\Metadata\\Attribute\\CustomIndex;\n\n#[ORM\\Table(name:'my_entity')]\n#[ORM\\Entity]\n#[CustomIndex(columns: ['my_property1'])]\n#[CustomIndex(columns: ['lower(my_property1)', 'lower(my_property2)'])]\nclass MyEntity\n{\n    #[ORM\\Column(type:'string', length: 256)]\n    private $myProperty1;\n    #[ORM\\Column(type:'string', length: 256)]\n    private $myProperty2;\n}\n```\n\nAvailable CustomIndex properties:\n\n* `columns` - array of the table columns\n* `name` - index name (default = `'i_cindex_\u003cmd5 hash from all CustomIndex attributes\u003e'`).\n* `unique` - index is unique (default = false).\n* `using` - corresponds to `USING` directive in PostgreSQL `CREATE INDEX` command.\n* `where` - corresponds to `WHERE` directive in PostgreSQL `CREATE INDEX` command.\n\nRequired only `columns` property.\n\n2) Use `intaro:doctrine:index:update` command for update db.\n\n```\nphp app/console intaro:doctrine:index:update\n```\n\nYou may use `dump-sql` parameter for dump sql with `DROP/CREATE INDEX` commands\n\n```\nphp app/console intaro:doctrine:index:update --dump-sql\n```\n\n## Examples\n\nCreate index using `pg_trgm` extension:\n```php\n\u003c?php\n\n#[CustomIndex(columns: ['lower(my_column) gist_trgm_ops'], using: 'gist')]\n```\n\nCreate unique index using PostgreSQL functions:\n```php\n\u003c?php\n\n#[CustomIndex(columns: ['lower(my_column1)', 'nullif(true, not my_column2 isnull)'], unique: true)]\n```\n\nCreate partial index:\n```php\n\u003c?php\n\n#[CustomIndex(columns: ['site_id'], where: 'product_id IS NULL')]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintaro%2Fcustom-index-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintaro%2Fcustom-index-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintaro%2Fcustom-index-bundle/lists"}