如何在 Symfony 5 中为迁移表添加前缀 [英] How to add a prefix to migrated tables in Symfony 5

查看:40
本文介绍了如何在 Symfony 5 中为迁移表添加前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习,正在构建一个与现有 PHP 项目共享数据库的 Symfony 5 应用程序.我的问题是关于为由学说迁移创建的所有表添加前缀.我找到了一些关于我想要做的事情的参考资料,但由于一些参考资料有点过时并且旧版本具有不同的目录结构等,我正在努力实现它们.

I'm currently learning as I go, building a Symfony 5 application which shares a database with an existing PHP project. My question is regarding adding a prefix to all tables created by doctrine migrations. I've found a couple of references to what I'm looking to do, but I'm struggling with their implementation due to some of the references being a little outdated and the older versions having different directory structures etc.

此链接 看起来很有希望,但我不确定应该在哪里添加它,它说:

This link looked to be promising but I'm unsure where this should be added, it says:

您在 library/DoctrineExtensions 目录中创建此文件

You create this file in your library/DoctrineExtensions directory

我找不到任何类似的目录.

I can't find any directories similar to it.

类似的东西,但对于 symfony 5?如何在symfony2中设置表前缀

Something like this but for symfony 5? How to setup table prefix in symfony2

我还查看了 this 但在 Composer 中尝试要求它时收到一条错误消息:

Also I looked at this but I got an error message when attempting to require it in composer:

问题 1- borsaco/doctrine-prefix-bundle ^1.0 的安装请求 -> borsaco/doctrine-prefix-bundle[1.0.0] 可满足.- borsaco/doctrine-prefix-bundle 1.0.0 需要 symfony/framework-bundle ^3.4|^4.0 -> 没有找到匹配的包.

Problem 1 - Installation request for borsaco/doctrine-prefix-bundle ^1.0 -> satisfiable by borsaco/doctrine-prefix-bundle[1.0.0]. - borsaco/doctrine-prefix-bundle 1.0.0 requires symfony/framework-bundle ^3.4|^4.0 -> no matching package found.

任何帮助/指针将不胜感激

Any help/pointers would be greatly appreciated

推荐答案

我遵循了@Dlk 的指南,不得不修改我的目录布局的 getPrefix() 函数,之后一切都很好,谢谢你们的帮助.:) 希望这会在未来帮助另一个新手!

I followed the guide from @Dlk, had to amend the getPrefix() func for my directory layout, after that all's good, thank you both for the help. :) Hopefully this'll help out another newbie in future!

这篇关于如何在 Symfony 5 中为迁移表添加前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆