0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[postgresql]本番データをステージングに突っ込んだ際の個人情報マスクする

0
Posted at

最近の勉強で学んだ事を、ノート代わりにまとめていきます。
主に自分の学習の流れを振り返りで残す形なので色々、省いてます。
Webエンジニアの諸先輩方からアドバイスやご指摘を頂けたらありがたいです!

個人情報をマスクする

[Heroku] ProductionのDatabasesをStagingに反映する!
Herokuで本番データをステージングに突っ込みたいけど個人情報やし、うかつに突っ込めない…

1.ステージングのpostgresqlに接続する

$ heroku pg:psql

2.emailをマスク化コマンド

replace、substring、strposの説明

update users set email = replace(email,substring(email, 1, strpos(email,'@')-1),concat('xxxxxxx_',id));

実行後、以下の様になる
xxxxxxx_1@gmail.com

3.nameをマスク化コマンド

update users set name = replace(name,substring(name, 1, length(name)),concat('xxx_',id));

実行後、以下の様になる
xxx_1

参考記事

マスク 【 mask 】
MySQLで個人情報をマスキング
mysqlでメールアドレスにマスクをかけるよ
運用に耐えるRailsによるWebアプリケーションの作り方
文字列関数と演算子

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?