Seed data on a tenant

Hi, I’m building a multi-tenant app using prefixes. I wish to seed data on a given prefix using two different ways:

  • using the command: mix run priv/repo/seeds.exs
  • in the application on tenant creation.
    Everytime I run the seed it only executes on the public schema. Is there a means of passing the tenant (prefix) as parameter to the CLI like the case of migrations? mix ecto.migrate --prefix="tenant"

You may want to give Triplex a try, or at the very least, have a read through the posts in this thread: Triplex - a complete solution to multi-tenancy with PG schemas to get some ideas.

3 Likes