Configure propel to create an index for every foreign-key automaticaly?
U018XELUZS9
Posts: 167 π§π»βπ - Cadet
Do you know if it's possible to configure propel to create an index for every foreign-key automatically when using Postgres?
Tagged:
0
Best Answer
-
We found the IndexGenerator Module, which is exactly what we need. We wrapped that in a bash script and added that to our CI pipeline:
#!/bin/bash export APPLICATION_ENV=development SCHEMA_DIR="src/Pyz/Zed/IndexGenerator/Persistence/Propel/Schema" TMP_DIR="/tmp/check-schema-changes/$(date -u +"%Y-%m-%d-%H-%M-%S")/" mkdir -p "$TMP_DIR" cp -a "$SCHEMA_DIR/." "$TMP_DIR" rm -rf src/Orm/Propel/MDE/Schema/*.xml rm -rf $SCHEMA_DIR/*.xml vendor/bin/console propel:schema:copy -q vendor/bin/console propel:postgres-indexes:generate -q DIFF_OUTPUT=$(diff "$SCHEMA_DIR" "$TMP_DIR") rm -rf "$TMP_DIR" if [ "$DIFF_OUTPUT" != "" ]; then echo "found missing indices, please generate them with: 'console propel:postgres-indexes:generate'" echo "you can find the generated files in '$SCHEMA_DIR'" echo "$DIFF_OUTPUT" exit 1 fi echo "there are no missing indices, good job"
0
Answers
-
Looks like this works already for MySQL: http://propelorm.org/blog/2012/03/05/don-t-do-this-at-home-4-add-indices-on-foreign-key-columns.html
0 -
@UQK3ZPJEN do you know if this is supported by Propel 2?
0 -
We found the IndexGenerator Module, which is exactly what we need. We wrapped that in a bash script and added that to our CI pipeline:
#!/bin/bash export APPLICATION_ENV=development SCHEMA_DIR="src/Pyz/Zed/IndexGenerator/Persistence/Propel/Schema" TMP_DIR="/tmp/check-schema-changes/$(date -u +"%Y-%m-%d-%H-%M-%S")/" mkdir -p "$TMP_DIR" cp -a "$SCHEMA_DIR/." "$TMP_DIR" rm -rf src/Orm/Propel/MDE/Schema/*.xml rm -rf $SCHEMA_DIR/*.xml vendor/bin/console propel:schema:copy -q vendor/bin/console propel:postgres-indexes:generate -q DIFF_OUTPUT=$(diff "$SCHEMA_DIR" "$TMP_DIR") rm -rf "$TMP_DIR" if [ "$DIFF_OUTPUT" != "" ]; then echo "found missing indices, please generate them with: 'console propel:postgres-indexes:generate'" echo "you can find the generated files in '$SCHEMA_DIR'" echo "$DIFF_OUTPUT" exit 1 fi echo "there are no missing indices, good job"
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 896 Developer Corner
- 758 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 23 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random