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

Question: how should sensitive data be handled in migratus? #264

Open
WorldsEndless opened this issue Jun 21, 2024 · 3 comments
Open

Question: how should sensitive data be handled in migratus? #264

WorldsEndless opened this issue Jun 21, 2024 · 3 comments

Comments

@WorldsEndless
Copy link

Migratus has been a great tool for initial design of our schemas and tables. In production, though, sensitive data enters the application. Encoding these as "up" migrations of insertions is desirable; it helps the developers work against real data. But how should that be saved? Our previous solution has been to make sure the project is private. For the time being, this refers to Github, and the migrations are just one folder along with our application code.

Searching, I find surprisingly little addressing the concern of storing sensitive data (names, phone numbers, requests and trouble-tickets) in database migration files. Surely this is a common encounter. How should I handle db migrations that include sensitive information in a secure but developer-accessible manner?

@yogthos
Copy link
Owner

yogthos commented Jun 21, 2024

One approach for doing this would be to use something like Selmer templates for the migrations and inject sensitive values during the build step in CI. So, you could have something like reosurces/templates/migrations, and then add a build task that compiles them into the actual migration files that are written into resources/migrations.

@ieugen
Copy link
Collaborator

ieugen commented Jun 21, 2024

I would not put sensitive data as migrations.
Migrations are for schema changes primarily, not for data changes.
If you do it for data changes I would see that as a red flag.
You could make data changes but mainly when schema changes and you need to split / merge add default values.

Have an import process for data and manage that as operational changes, not schema migrations.
Import / export feature in the app.

@yogthos
Copy link
Owner

yogthos commented Jun 22, 2024

I agree with that as well, as a rule it's best to keep data and app separate. My approach has been to keep the jar environment agnostic, and then inject any environment specific data such as db connections, access tokens, etc. as environment variables into containers during deployment. Then the jar starts up and picks up the environment at runtime.

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