Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi, I have a question regarding the IndexGenerator. When we run the IndexGenerator it will create so

Options
UKMHZV8LX
UKMHZV8LX Posts: 69 🧑🏻‍🚀 - Cadet

Hi, I have a question regarding the IndexGenerator.
When we run the IndexGenerator it will create some schema definition files in Pyz/Zed/IndexGenerator/Persistence/Propel/Schema where missing indices will be defined.
However when you run the IndexGenerator once again, it will delete those files. I assume this happens, because IndexGenerator will find the indices already exist in the database and hence no additional files are required.
So far we used to put the generated files under version control, but I think there is a misunderstanding on our end.
How is the intended way to use the IndexGenerator? Would it be the intended way to copy the schema files or their content into the specific module folders the files belong to?
Happy about any advice 🙂

Comments

  • U01T075RRHD
    U01T075RRHD Posts: 118 🧑🏻‍🚀 - Cadet
    Options

    If you track your migration files that should not be an issue

  • UKMHZV8LX
    UKMHZV8LX Posts: 69 🧑🏻‍🚀 - Cadet
    Options

    How would tracking migration files help here?

  • U01T075RRHD
    U01T075RRHD Posts: 118 🧑🏻‍🚀 - Cadet
    edited December 2021
    Options

    As far as I understood, the index generator scans the database for missing indexes and creates schema files for them. Once these schema files are created you can create a migration that includes the respective changes that need to get applied to the tables. Once this migration is created you won't need the schema files any more.
    If you track the migrations, your good

  • UKMHZV8LX
    UKMHZV8LX Posts: 69 🧑🏻‍🚀 - Cadet
    Options

    But when you run the IndexGenerator again, the files will be removed. Hence subsequently generated migration will also delete the indices.

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    The Index Generator does not scan the database, but only the schema files. We use it in a CI job, that not even has a running database service.

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    The files are removed, because the generated index is already copied/merged to src/Orm/Propel/MDE/Schema probably

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    The files in src/Pyz/Zed/IndexGenerator/Persistence/Propel/Schema are also in our repository and are not ignored

  • UKMHZV8LX
    UKMHZV8LX Posts: 69 🧑🏻‍🚀 - Cadet
    Options

    My main question is, if the generated files should remain in the folder or moved around.

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    They remain in the folder (src/Pyz/Zed/IndexGenerator/Persistence/Propel/Schema) in our project. It does not make any difference, since vendor/bin/console propel:schema:copy will iterate over all schema files from all modules, merge them and copy the result to src/Orm/Propel/MDE/Schema.

  • UKMHZV8LX
    UKMHZV8LX Posts: 69 🧑🏻‍🚀 - Cadet
    Options

    But this folder is excluded from VC by default.

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    You mean src/Orm/Propel/MDE/Schema?

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    This makes sense, since these are only generated files, based on what you have in your modules. Think of it as a representation of your database schema on the filesystem.

  • UKMHZV8LX
    UKMHZV8LX Posts: 69 🧑🏻‍🚀 - Cadet
    Options

    Yes and so it does not solve the issue.

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    Did you already try the script I posted?

  • U018XELUZS9
    U018XELUZS9 Posts: 167 🧑🏻‍🚀 - Cadet
    Options

    We had the exact same issue and this is our solution