php - 在 Symfony 中使用 Doctrine DBAL 模式表示
问题描述
我一直在使用 Symfony 4+ 开发一些 Web 应用程序,我正在 MariaDB 上开发,但也希望可以选择部署到其他数据库。
当我生成数据库迁移时,它是使用 SQL 查询生成的,如下所示:
public function up(Schema $schema) {
$this->addSql('CREATE TABLE users ...');
}
public function down(Schema $schema) {
$this->addSql('DROP TABLE users');
}
我希望迁移使用模式表示并像这样生成:
public function createSchema() {
$schema = new Schema();
$table = $schema->createTable('users');
$table->addColumn('id', 'integer', array(
'autoincrement' => true,
));
$table->setPrimaryKey(array('id'));
return $schema;
}
}
有没有办法配置 Symfony 或 DoctrineMigrationsBundle 以使用模式表示生成迁移?
(有点像,但不必与Laravel 的迁移完全匹配。)
解决方案
推荐阅读
- jquery - 如何检测数组中的相同元素并总结数量?
- javascript - 产品路线未定义且未显示在前端 ReactJS 部分,mongoDB
- visual-studio-code - 我无法在 Visual Studio Code 中打开终端
- reactjs - Gatsby - 如何使用 GraphQL 查询 src/data/ 子文件夹中的所有 YAML
- javascript - Angular如何在组件中的属性更改时执行功能
- html - 网格内的绝对项目没有根据需要采取全高
- javascript - 只有被点击的视频应该播放
- c# - C# Visual Studio 在查看 UI 时返回异常
- swift - 当一个结构的元组被另一个结构持有时,为什么编译需要很长时间?
- maven - 限制 jenkins maven 作业在多云设置中的特定云上运行