fix(migrations): drop double table_prefix in Phinx hasTable/table calls (#276)#277
Merged
Merged
Conversation
… calls (#276) PR #271 defensive-checks accidentally passed prefixed names to Phinx API methods that auto-prefix internally — every check became modx_modx_* lookup that never matched, so seed migrations silently no-op'd. Fixed all 9 affected migrations: - seed_customers/orders/order_products/deliveries/vendors/category_products_grid_config - fix_orders_grid_filterable - update_orders_grid_status_fields - add_duplicate_publish_to_category_products_actions Plus initial_schema: - addForeignKeys(): hasTable / $this->table / addForeignKey target — same fix. FK constraints were never created on fresh installs because of this. - down(): drop loop — same fix. Phinx API now gets UNPREFIXED names. Raw SQL via $this->execute / fetchAll keeps {$prefix}name (no auto-prefix there). Comment added on the bug for future readers. Impact: fresh MS3 ≥ 1.10.1 installs now properly seed ms3_grid_fields default rows and create FK constraints. Existing installs that ran the seeds before #271 are unaffected (already in phinxlog).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
В PR #271 defensive-checks для
ms3_grid_fieldsнаписаны с ручным префиксом:TablePrefixAdapter::hasTable($name)сам добавляетtable_prefixвнутри — итого Phinx искалmodx_modx_ms3_grid_fields, не находил, миграция уходила в no-op. То же касается$this->table($name)/hasColumn.Тип изменений
Связанные Issues
Closes #276
Refs #270 (root cause defensive checks для пользователей не работали)
Воздействие
ms3_grid_fieldsсоздавалась черезinitial_schema, но из-за двойного префикса в defensive-checks не наполнялась. Гриды (заказы, клиенты, доставки, оплаты, вендоры, позиции, товары категории) загружались без default-конфигурации.phinxlog, не затронуты.initial_schema::addForeignKeys(): тот же баг — FK constraints никогда не создавались на свежих установках.Состав
Поправлены 10 миграций (9 затронутых #271 + initial_schema):
20251020000000_initial_schema.php—addForeignKeys()(hasTable + $this->table + addForeignKey target) иdown()drop loop.20251127000002_seed_customers_grid_config.php20251204140000_seed_orders_grid_config.php20251215120000_seed_order_products_grid_config.php20251222120000_seed_deliveries_grid_config.php20251223130000_seed_vendors_grid_config.php20251231140000_seed_category_products_grid_config.php20260107120000_fix_orders_grid_filterable.php20260119220000_update_orders_grid_status_fields.php20260317120000_add_duplicate_publish_to_category_products_actions.phpPhinx API-методы (
hasTable,\$this->table(),hasColumn,addForeignKeytarget) теперь получают UNPREFIXED имя. Raw SQL через\$this->execute()/fetchRow()/fetchAll()по-прежнему получает{\$prefix}name(он не префиксируется автоматически).Тестирование
На dev-сайте (с уже наполненной `ms3_grid_fields`):
PHPStan для миграций не применим (Phinx-классы не в paths).