Doctrine Migrations: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
(Created page with "<syntaxhighlight lang="yaml"> # app/config/parameters.yml parameters: database_host: ~ database_port: ~ database_name: ~ database_user: ~ database_password...")
 
No edit summary
Line 1: Line 1:
===Parameters===
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
# app/config/parameters.yml
# app/config/parameters.yml
Line 15: Line 16:
</syntaxhighlight>
</syntaxhighlight>


===Doctrine Config===
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
# app/config/config.yml
# app/config/config.yml
Line 28: Line 30:
</syntaxhighlight>
</syntaxhighlight>


===Database Creation===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cd /symfony/project/dir;
cd /symfony/project/dir
mkdir -p ./var/sqlite/;
touch ./var/sqlite/.gitkeep;


# create sqlite dir
mkdir -p ./var/sqlite/;\
touch ./var/sqlite/.gitkeep
# sqlite database create by doctrine  
# sqlite database create by doctrine  
bin/console doctrine:database:create
bin/console doctrine:database:create
Line 39: Line 43:
</syntaxhighlight>
</syntaxhighlight>


===Migrations Config===
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
# app/config/config.yml
# app/config/config.yml

Revision as of 10:32, 12 January 2018

Parameters

# app/config/parameters.yml
parameters:
    database_host: ~
    database_port: ~
    database_name: ~
    database_user: ~
    database_password: ~
    database_path: '%kernel.root_dir%/../var/sqlite/chorke.db'
    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

cd /symfony/project/dir

# create sqlite dir
mkdir -p ./var/sqlite/;\
touch ./var/sqlite/.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

# app/config/config.yml
doctrine_migrations:
    dir_name: "%kernel.root_dir%/DoctrineMigrations"
    namespace: Application\Migrations
    table_name: m00m00
    name: Application Migrations
    organize_migrations: false