Skip to content

Conversation

@sincilite
Copy link

In response to #180 and my own requirement to manage multiple databases for a single application I've implemented the ability to specify multiple database connections within the Phinx config and within many environments and have each track it's own migrations.

The existing functionality remains and it is still possible to use the original configuration schema of environments and single database connections as child properties. To ensure backwards compatibility the root paths options must remain in config even when using multiple databases with their own migration and seed paths specified.

development:
        db_ref_1:
            paths:
                migrations: '%%PHINX_CONFIG_DIR%%/db/migrations/mysql'
                seeds: '%%PHINX_CONFIG_DIR%%/db/seeds/mysql' 
            adapter: mysql
            host: 127.0.0.1
            name: development_db
            user: root
            pass: ''
            port: 3306
            charset: utf8

        db_ref_2:
            paths:
                migrations: '%%PHINX_CONFIG_DIR%%/db/migrations/mysql-2'
                seeds: '%%PHINX_CONFIG_DIR%%/db/seeds/mysql-2' 
            adapter: mysql
            host: 127.0.0.1
            name: development_db
            user: root
            pass: ''
            port: 3307
            charset: utf8

Migrations and seed files are separated in different directories and can still utilise namespacing if required.

The command seeds:run has been updated to allow an optional -d or --database option with the expected value being the database reference specified in the config (e.g. db_ref_1)

Mike van Rooyen added 30 commits November 14, 2017 10:03
@codecov-io
Copy link

codecov-io commented Nov 24, 2017

Codecov Report

Merging #1241 into master will increase coverage by 0.22%.
The diff coverage is 83.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1241      +/-   ##
==========================================
+ Coverage   74.63%   74.86%   +0.22%     
==========================================
  Files          35       35              
  Lines        4739     4881     +142     
==========================================
+ Hits         3537     3654     +117     
- Misses       1202     1227      +25
Impacted Files Coverage Δ
src/Phinx/Console/Command/Rollback.php 96.61% <100%> (+1.61%) ⬆️
src/Phinx/Console/Command/Status.php 100% <100%> (ø) ⬆️
src/Phinx/Console/Command/AbstractCommand.php 52.34% <62.5%> (+1.45%) ⬆️
src/Phinx/Migration/Manager.php 87.41% <66.66%> (-2.62%) ⬇️
src/Phinx/Console/Command/SeedRun.php 81.81% <70.83%> (-10.69%) ⬇️
src/Phinx/Console/Command/Migrate.php 94.44% <81.81%> (+6.07%) ⬆️
src/Phinx/Config/Config.php 99.48% <98.48%> (-0.52%) ⬇️
src/Phinx/Db/Adapter/PostgresAdapter.php 93.73% <0%> (+0.02%) ⬆️
src/Phinx/Seed/AbstractSeed.php 48.83% <0%> (+2.49%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd6f205...480cc82. Read the comment docs.

@piotr-cz piotr-cz mentioned this pull request Nov 22, 2018
@dereuromark
Copy link
Member

Conflicts
This will add quite the complexity to the system - but if done in a good way I think it would be acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants