我当前在数据库中具有以下布局:
我们正在研究一个新概念,在该概念中,我们添加了一个微服务,用于处理流入遗留数据库的所有内容以及处理出站流的服务。 这些应用程序本身运行良好。
我当前面临的唯一真正问题是教义和教义的迁移。
每次运行diff时,我们也会在其中包含所有旧版db条目,并且需要将其删除。
我们希望保留理论迁移,因为它们与类迁移文件很好地集成到了我们的概念中。 在任何情况下都不应更新旧版数据库,但始终会将它们插入这些文件中。 我们使用以下命令运行diff:
./ bin /控制台学说:migrations:diff --em = application
此命令应排除遗留数据库,因为它们是在配置中完全不同的实体管理器中注册的。
配置文件:
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_APPLICATIONURL): ''
env(DATABASE_LEGACY_DB_URL): ''
env(DATABASE_LEGACY_LOG_URL): ''
env(DATABASE_LEGACY_OUT_URL): ''
doctrine:
dbal:
default_connection: application
connections:
application:
url: '%env(DATABASE_APPLICATIONURL)%'
server_version: '5.7'
charset: '%env(DATABASE_APPLICATIONCHARSET)%'
default_table_options:
charset: '%env(DATABASE_APPLICATIONCHARSET)%'
collate: '%env(DATABASE_APPLICATIONCOLLATE)%'
legacydb:
url: '%env(DATABASE_LEGACY_DB_URL)%'
server_version: '5.7'
charset: '%env(DATABASE_LEGACY_DB_CHARSET)%'
default_table_options:
charset: '%env(DATABASE_LEGACY_DB_CHARSET)%'
collate: '%env(DATABASE_LEGACY_DB_COLLATE)%'
legacylog:
url: '%env(DATABASE_LEGACY_LOG_URL)%'
server_version: '5.7'
charset: '%env(DATABASE_LEGACY_LOG_CHARSET)%'
default_table_options:
charset: '%env(DATABASE_LEGACY_LOG_CHARSET)%'
collate: '%env(DATABASE_LEGACY_LOG_COLLATE)%'
legacyout:
url: '%env(DATABASE_LEGACY_OUT_URL)%'
server_version: '5.7'
charset: '%env(DATABASE_LEGACY_OUT_CHARSET)%'
default_table_options:
charset: '%env(DATABASE_LEGACY_OUT_CHARSET)%'
collate: '%env(DATABASE_LEGACY_OUT_COLLATE)%'
orm:
default_entity_manager: application
auto_generate_proxy_classes: '%kernel.debug%'
entity_managers:
application:
connection: application
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
Application:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/COMPANY/entitybundle/src/Entity/Application'
prefix: 'Application\Entity\Entity\Application'
alias: App
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable # (optional) it will default to the name set for the mapping
is_bundle: false
gedmo_sortable:
type: annotation
prefix: Gedmo\Sortable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Sortable/Entity"
alias: GedmoTree
is_bundle: false
gedmo_loggable:
type: annotation
prefix: Gedmo\Loggable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
alias: GedmoLoggable # (optional) it will default to the name set for the mappingmapping
is_bundle: false
gedmo_tree:
type: annotation
prefix: Gedmo\Tree\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
alias: GedmoTree # (optional) it will default to the name set for the mapping
is_bundle: false
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
legacydb:
connection: legacydb
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
mappings:
InDB:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/COMPANY/entitybundle/src/Entity/LegacyDb'
prefix: 'Application\Entity\LegacyDb'
alias: legacydb
legacylog:
connection: legacylog
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
mappings:
LogDB:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/COMPANY/entitybundle/src/Entity/LegacyLog'
prefix: 'Application\Entity\LegacyLog'
alias: legacylog
legacyout:
connection: legacyout
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
mappings:
CacheDB:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/COMPANY/entitybundle/src/Entity/LegacyOut'
prefix: 'Application\Entity\LegacyOut'
alias: legacyout
将它们分开是很重要的,因为遗留表迟早会被删除,但无法被删除,并且应用程序需要立即处理它们,直到可以删除遗留系统。
我如何告诉学说迁移忽略实体管理器中的所有实体?