Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating on existing tenants in Production #66

Open
churcho opened this issue Mar 19, 2019 · 6 comments
Open

Migrating on existing tenants in Production #66

churcho opened this issue Mar 19, 2019 · 6 comments

Comments

@churcho
Copy link

churcho commented Mar 19, 2019

How do you run migrations in production environments with no mix?

I made changes to some of my tables and would like to propagate this to already existing tenants.

Do we need to keep a table with existing [tenants]?(

tenant_table: :tenants
)

@kelvinst
Copy link
Contributor

@churcho sorry it took so long, what do you mean? mix triplex.migrate should do that for your (running the migrations on all existing tenants). Please checkout the docs for it: https://hexdocs.pm/triplex/Mix.Tasks.Triplex.Migrate.html#content

@kelvinst
Copy link
Contributor

kelvinst commented May 31, 2019

If you use release though, that is a little bit trickier, but you can combine Triplex.all with Triplex.migrate and migrate all of the tenants on the database on your remote console.

@stueccles
Copy link

@kelvinst it would be nice if

Enum.each(Triplex.all, &Triplex.migrate(&1) end)

worked but alas it doesn't as Triplex.all returns a list of prefixes which Triplex.migrate then applies to_prefix on again...

it is not difficult to work around and running

Enum.each(Triplex.all, &Ecto.Migrator.run(
          My.Repo,
          Triplex.migrations_path(My.Repo),
          :up,
          all: true,
          prefix: &1
        ))

works in a production terminal to do the tenant migrations.

@kelvinst
Copy link
Contributor

kelvinst commented Sep 16, 2019 via email

@kelvinst
Copy link
Contributor

kelvinst commented Sep 16, 2019 via email

@kelvinst
Copy link
Contributor

Anyway, we are currently working on a braking change that would force some people to add another lib to their projects if they want the plugs, so why not? 🤷‍♂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants