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 Please let me know whether there is any way in spryker to seed data in database. Like I need to a

U03TXRYL7U7
U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi
Please let me know whether there is any way in spryker to seed data in database.
Like I need to add some data in database master table.
Is there any way to add that without manually adding data in table?

Comments

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 πŸͺ - Explorer

    Yes there is a way, called installers:

    You can have a look at \Pyz\Zed\Installer\InstallerDependencyProvider::getInstallerPlugins to see plenty of examples on how to implement such an installer that seeds data into the database.
    The LocaleInstaller would be a very good and easy example how this is implemented: \Spryker\Zed\Locale\Business\Internal\Install\LocaleInstaller

  • U03TXRYL7U7
    U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok thanks
    I am checking the code, it should work fine.
    It seems that this installer is called from LocaleInstallerPlugin. and please let me know how can we call this plugin.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 πŸͺ - Explorer

    setup:init-db command will execute all installers. As this runs on every deployment in the Spryker PaaS you should ensure that your installer is idempotent, meaning it can run more than once without sideeffects.

  • U03TXRYL7U7
    U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    and how can I run setup:init-db on my local.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 πŸͺ - Explorer

    Like any other command: docker/sdk console setup:init-db

  • U03TXRYL7U7
    U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok thanks
    Will try to implement the same and will ping if will find any issues during implementation

  • U03TXRYL7U7
    U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UL6DGRULR thanks for your help. I was able to seed data from above command.

  • U03TXRYL7U7
    U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UL6DGRULR Please let me know whether there is any option in docker/sdk console setup:init-db to run only one specific plugin for installer. Currently to proceed with the installer on which I am working, I am commenting remaining plugins.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 πŸͺ - Explorer

    There is no option to run only a certain installer, but all installers should be idempotent, so running them more than once should not be an issue and there is no need to comment the remaining plugins

  • U03TXRYL7U7
    U03TXRYL7U7 Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    okay. Thanks