Doctrine Migrations: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
Line 43: Line 43:


===Migrations Config===
===Migrations Config===
Finally, be sure to enable the bundle in <code>AppKernel.php</code> by including the following:
<syntaxhighlight lang="php">
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        //...
        new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
    );
}
</syntaxhighlight>
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
# app/config/config.yml
# app/config/config.yml
Line 48: Line 61:
     dir_name: "%kernel.root_dir%/DoctrineMigrations"
     dir_name: "%kernel.root_dir%/DoctrineMigrations"
     namespace: Application\Migrations
     namespace: Application\Migrations
     table_name: T00D00
     table_name: T00000
     name: Application Migrations
     name: Application Migrations
     organize_migrations: false
     organize_migrations: false
</syntaxhighlight>
</syntaxhighlight>

Revision as of 03:50, 13 January 2018

Parameters

# app/config/parameters.yml
parameters:
    database_host: ~
    database_port: ~
    database_name: ~
    database_user: ~
    database_password: ~
    database_path: '%kernel.root_dir%/../var/rdbms/chorke.sqlite '
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: ~
    mailer_password: ~
    secret: ff1a949ebf4d50f1f51a1fb3864f52e9e5c9e136

Doctrine Config

# app/config/config.yml
doctrine:
    dbal:
        driver: pdo_sqlite
        path: '%database_path%'
        charset: UTF8
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

Database Creation

# var/sqlite/.gitkeep
mkdir -p ./var/rdbms/;\
touch ./var/rdbms/.gitkeep

# sqlite database create by doctrine 
bin/console doctrine:database:create
# doctrine migrations dependency require
composer require doctrine/doctrine-migrations-bundle "^1.0"

Migrations Config

Finally, be sure to enable the bundle in AppKernel.php by including the following:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        //...
        new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
    );
}
# app/config/config.yml
doctrine_migrations:
    dir_name: "%kernel.root_dir%/DoctrineMigrations"
    namespace: Application\Migrations
    table_name: T00000
    name: Application Migrations
    organize_migrations: false