Giter VIP home page Giter VIP logo

doctrine-multi-schema-bundle's Introduction

Enables Multiple Schemas for MySQL on Doctrine

I created this bundle to fulfill a need for one of my projects. It is not thoroughly tested for all use cases, and will be regularly updated.

If you find this useful but spot a bug, I welcome PRs.

The Premise

Doctrine treats MySQL databases the same as PostgreSQL databases. The truth is that MySQL databases are closer in nature to a PostgreSQL schema, and the term DATABASE can be used interchangeably with SCHEMA in MySQL, even in syntax:

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name ...

This makes it very difficult to handle MySQL layouts that use more than one schema - often a reality in inherited code.

If your personal use case is transferring an existing project with multiple schemas into a Symfony project, and you'd like to use Doctrine, then this bundle seeks to make that possible.

Installation

In your Symfony project, install with

composer require shoofly/doctrine-multi-schema-bundle

Add to your Symfony AppKernel.php:

$bundles = [
    new Shoofly\DoctrineMultiSchemaBundle\ShooflyDoctrineMultiSchemaBundle(),
];

Configuraiton

IMPORTANT: Remove your driver and platform, and replace it with these two parameters.

doctrine:
    dbal:
        driver_class: 'Shoofly\DoctrineMultiSchemaBundle\DBAL\MySQL\Driver'
        platform_service: "shoofly_doctrine_multi_schema.platform57"
        # for MySQL < 5.7, choose this:
        # platform_service: "shoofly_doctrine_multi_schema.platform"

Next, list the schemas you want to include in your ORM:

shoofly_doctrine_multi_schema:
    schemas:
        - foo
        - baz
        - bar

That should be the only configuration you need. If you run into any issues, please let me know.

Hope this helps someone else. If not, it's already helped me :)

doctrine-multi-schema-bundle's People

Contributors

smcjones avatar

Watchers

 avatar

doctrine-multi-schema-bundle's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.