Migrating on existing tenants in Production
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]?(https://github.com/ateliware/triplex/blob/f49c43fc41169818a1454b3eb3ff5c3bc4815e4d/lib/triplex/config.ex#L19)
@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
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.
@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.
Yeah, we actually need to think of better ways of doing those. Maybe a Triplex.migrate_all function would make it easier, but we still have to come up with a better way to decide when to apply to_prefix and when not to apply it. I just can’t figure any way of doing that without breaking the API so hard that we would need to bump the version to 2.0.
Best, Kelvin Stinghen [email protected]
On Sep 16, 2019, at 16:24, Stuart Eccles [email protected] wrote:
@kelvinst https://github.com/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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ateliware/triplex/issues/66?email_source=notifications&email_token=AAVJUHKX5RZMWH5423G7P5TQJ7MOBA5CNFSM4G7OI6I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD62HTJI#issuecomment-531921317, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVJUHNQWSRYBT2ULXXOZRDQJ7MOBANCNFSM4G7OI6IQ.
We’re open to suggestions though.
Best, Kelvin Stinghen [email protected]
On Sep 16, 2019, at 16:55, Kelvin Stinghen [email protected] wrote:
Yeah, we actually need to think of better ways of doing those. Maybe a
Triplex.migrate_allfunction would make it easier, but we still have to come up with a better way to decide when to applyto_prefixand when not to apply it. I just can’t figure any way of doing that without breaking the API so hard that we would need to bump the version to 2.0.Best, Kelvin Stinghen [email protected] mailto:[email protected]
On Sep 16, 2019, at 16:24, Stuart Eccles <[email protected] mailto:[email protected]> wrote:
@kelvinst https://github.com/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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ateliware/triplex/issues/66?email_source=notifications&email_token=AAVJUHKX5RZMWH5423G7P5TQJ7MOBA5CNFSM4G7OI6I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD62HTJI#issuecomment-531921317, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVJUHNQWSRYBT2ULXXOZRDQJ7MOBANCNFSM4G7OI6IQ.
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? 🤷♂