roukmoute/doctrine-prefix-bundle

Listener that prefixes tables and sequences

v1.0.2 2020-01-15 11:02 UTC

This package is auto-updated.

Last update: 2024-03-27 12:04:59 UTC


README

SensioLabsInsight

DoctrinePrefixBundle

This bundle prefixes tables and, if you are using PostgreSQL, sequences with a string of your choice by changing the metadata of your entities. Prefixes are good if you need to share a database with tables from another project, or if you want to name your entities using reserved keywords like user or group.

Installation

composer require roukmoute/doctrine-prefix-bundle

Configuration

First, you need to register the bundle in your application kernel, like this :

<?php
//app/AppKernel.php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            …
            new Roukmoute\DoctrinePrefixBundle\RoukmouteDoctrinePrefixBundle()
        );
        …

The configuration looks as follows :

roukmoute_doctrine_prefix:

    # will be prepended to table and sequence names
    prefix:               sf

    # if set, the prefix will be applied to specified bundles only
    bundles:              []

    # the encoding to convert the prefix to
    encoding:             UTF-8