technogise / dynamo-data-migrations

Dynamo DB data migration tool
MIT License
29 stars 7 forks source link

Cant make coexist two env in the same aws profile #26

Open dservidie opened 3 months ago

dservidie commented 3 months ago

First of all, I wanted to thank you for your work on this tool. I am having trouble making coexist two envs in the same AWS account, since the tables of our envs are differentiated by name. Ex: TableOne-Dev TableTwo-Dev

TableOne-Prod TableTwo-Prod

I understand the tool is thought to use the --profile dev/stage/prod. But it doesn't work in our case.

But when we want to run migrations the tool cant know what migrations were already run in Dev and what were run in Prod, since all are stored in the same place (MIGRATIONS_LOG_DB).

This forced us to duplicate the migrations naming them: 1716864675190-migration-one-DEV.mjs and 1716864675190-migration-one-PROD.mjs, so the same database can store history for both ends in parallel.

Could you please add a config that allows us to specify the env? For example: dynamo-data-migrations up --env [Prod] to allow us to differentiate different envs.

The same could happen for other users that use your tool with two different apps. They should be careful of not having the same name in two files of their apps (unlikely, but possible)

That might be very helpful. The tool could use that env parameter to use a different table like: MIGRATIONS_LOG_DB_DEV and MIGRATIONS_LOG_DB_PROD. It might also work if the differentiation is done by adding a field like ENV to the current MIGRATIONS_LOG_DB table like:

ENV: Dev
FILE_NAME: 1716864675190-migration-one.mjs
APPLIED_AT: 2024-05-30T11:32:19.478Z

ENV: Prod
FILE_NAME: 1716864675190-migration-one.mjs
APPLIED_AT: 2024-05-30T11:32:19.478Z

It would also do the trick for us, If you allow us to define the name of the table where the migrations log is stored like: dynamo-data-migrations up --log-table MIGRATIONS_LOG_DB_DEV dynamo-data-migrations up --log-table MIGRATIONS_LOG_DB_PROD

ChipiKaf commented 2 months ago

I'm currently facing the same challenge. Any workarounds for this perhaps?

dservidie commented 2 months ago

I'm currently facing the same challenge. Any workarounds for this perhaps?

I'm afraid not, @ChipiKaf . I still haven't figured out how to solve it. I have considered forking from this project and adapting it to my needs, but I'm still hopeful to find another solution.

dservidie commented 1 month ago

@ChipiKaf I forked from this project and created a package with the new feature of changing the prefix of the migrations table: https://github.com/dservidie/dynamo-data-migrations https://www.npmjs.com/package/@dservidie/dynamo-data-migrations

ChipiKaf commented 1 month ago

Hi @dservidie . Thanks. Will give it a try!