如何在生产环境中使用数据库夹具

问题描述 投票:1回答:3

我想知道如何在生产环境中使用Doctrine灯具。例如,当我想预定义一组固定的权限或超级用户等时。

Doctrine documentation states

Fixtures用于将“假”数据集加载到数据库中,然后可以在开发应用程序时用于测试或帮助您提供一些有趣的数据。

因此,我不想使用自己的灯具,因为它会违背它的概念。

有任何想法吗?

symfony doctrine-orm
3个回答
3
投票

我找到了这个here的一个很好的答案:

通常,建议的操作是使用迁移。使用dump-sql运行fixture代码,并将其移动到可以在任何服务器中一致部署的迁移中。

希望这对其他人也有帮助!


1
投票

你也可以使用带有--append选项的灯具,它不会清除数据库。 Documentation

php bin/console doctrine:fixtures:load --append --fixtures=/path/to/production/fixtures1 --fixtures=/path/to/production/fixtures2

1
投票

您只需将其添加到命令行:

--env = PROD

© www.soinside.com 2019 - 2024. All rights reserved.