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

[BUG] Generated emails & usernames aren't unique #14

Open
psociety opened this issue Aug 10, 2021 · 0 comments
Open

[BUG] Generated emails & usernames aren't unique #14

psociety opened this issue Aug 10, 2021 · 0 comments

Comments

@psociety
Copy link

If you have a UNIQUE index set for those fields, anonymize will break the dump as there's no option for truly unique emails/usernames.

My work around has been to add new transformation functions:

// add these imports
import (
    "strconv"
    "time"
)

func generateUniqueEmail(value *sqlparser.SQLVal) *sqlparser.SQLVal {
	return sqlparser.NewStrVal([]byte(strconv.Itoa(int(time.Now().UnixNano())) + "@gmail.com"))
}
func generateUniqueUsername(value *sqlparser.SQLVal) *sqlparser.SQLVal {
	return sqlparser.NewStrVal([]byte(faker.Internet().UserName() + strconv.Itoa(int(time.Now().UnixNano()))))
}
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

1 participant