Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8300183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:27:02+00:00 2026-06-08T16:27:02+00:00

I have a dev database that I periodically rebuild from a data dump of

  • 0

I have a dev database that I periodically rebuild from a data dump of the prod database. After doing the initial rebuild, I have a cleanup script that I run that does a few things, notably changing all emails to a dev address so our customers don’t get spammed inadvertently when we develop. This worked fine until I changed the structure of our db so that each customer can have multiple emails, with a unique constraint disallowing the same email multiple times per customer. Now I am trying to rewrite my cleanup script to change all emails to “xyzpdq@abc.com” but it’s failing because of the unique constraint.

I don’t want remove the unique constraint on my dev db for obvious reasons. I need to figure out a method to assign fake but unique emails for the customers that have multiple contacts.

Here’s my data structure:

CREATE TABLE contact (
    contactid decimal(22,0) DEFAULT '0' NOT NULL,
    ...,
    PRIMARY KEY (contactid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE contact_email (
    contactemailid decimal(22,0) DEFAULT '0' NOT NULL,
    contactid decimal(22,0) DEFAULT '0' NOT NULL,
    emailaddress varchar(255) COLLATE latin1_bin NOT NULL,
    PRIMARY KEY (contactemailid),
    CONSTRAINT ce_contactid_fk FOREIGN KEY (contactid) REFERENCES contact (contactid) ON DELETE NO ACTION ON UPDATE NO ACTION,
    INDEX ce_contactid_fk (contactid),
    CONSTRAINT ce_uniquecombokey UNIQUE KEY (contactid, emailaddress)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE merchant_contact (
    merchantcontactid decimal(22,0) DEFAULT '0' NOT NULL,
    merchantacctid decimal(22,0) DEFAULT '0' NOT NULL,
    contactid decimal(22,0) DEFAULT '0' NOT NULL,
    billingcontact tinyint(1) default '0' NOT NULL,
    PRIMARY KEY (merchantcontactid),
    CONSTRAINT mc_contactid_fk FOREIGN KEY (contactid) REFERENCES contact (contactid) ON DELETE NO ACTION ON UPDATE NO ACTION,
    INDEX mc_contactid_fk (contactid),
    CONSTRAINT mc_uniquecombokey UNIQUE KEY (merchantacctid, billingcontact)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Before I allowed multiple emails per customer, this part of my cleanup script was easy:

update contact_email set emailaddress = 'xyzpdq@abc.com';

Now it fails because of the constraint. I get an Error Code: 1062, SQL State: 23000 (integrity constraint violation).

Any suggestions? Thanks in advance. I’m going to continue to hammer on it myself, but would appreciate suggestions/ideas from experienced SQL scripters.

ETA: Thanks for the ideas so far. One thing I left out is that the fake address that I currently set them all to, actually does come to me, so I can see the email when I am testing. I am asking our ops group if something like ‘dev-{contactemailid}@abc.com’ could be configured to all come to me, but I’m not too optimistic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:27:05+00:00Added an answer on June 8, 2026 at 4:27 pm
    update contact_email set emailaddress = CONCAT(contactemailid, 'xyzpdq@abc.com')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Dev database that was cloned from a prod DB and was
I have an R script that pulls data from a MySQL database, processes it,
I am using SQL-Server 2005. I have a dev and prod database that have
I have a typical dev scenario: I have a SQL 2008 database that I
In my database I have certain data that is important to the functioning of
I have a dev server in our office that is behind the firewall. The
We have a dev server that has managed to become indexed by Google. Page
I have a dev team that is split in mentality of using visual studio
I have an app in dev that involves a small list of people, a
Using CouchDB to create a hosted app for clients. I have a dev database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.