Failed to add site to database. DBERR: error ‘ERROR: duplicate key violates unique constraint “domain_key” ‘ in ‘ INSERT INTO siteinfo ENSIM
Hello guys, You might have come accross the following error
Failed to add site to database. DBERR: error ‘ERROR: duplicate key violates unique constraint “domain_key” ‘ in ‘ INSERT INTO siteinfo (site_id, domain, admin_user, email) VALUES (8, ‘domain.com’, ‘xxxx’, ‘xxx@domain.com’)’
=========================
Here is the fix.
Login to server via backend.
su postgres
Take a backup of the database…
pg_dump appldb > appldb.dump.out
Now lets edit
psql
postgres=# \l
this will list all the databases. The Ensim database is “appldb”
postgres=# \c appldb
You are now connected to database “appldb”.
appldb=# \d
This will list all the tables in the database.
You can find the database siteinfo
appldb=# SELECT * FROM siteinfo WHERE domain=’domain.com’;
site_id | domain | email | admin_user
———+——————–+———————+————
35 |domain.com | test@yahoo.com | dommn
(1 row)
it will list the entry. Now to fix the issue, you need to delete that entry. Find the site_id for the domain. Here it is 35
DELETE FROM siteinfo WHERE site_id=35;
Now quit the database
appldb=# \q
bash-3.00$ exit
Restart services
/etc/rc.d/init.d/virtualhosting restart
/etc/rc.d/init.d/epld restart
Now try to add the domain from Control panel.





3 Responses to Failed to add site to database. DBERR: error ‘ERROR: duplicate key violates unique constraint “domain_key” ‘ in ‘ INSERT INTO siteinfo ENSIM
madtux
March 6th, 2009 at 6:57 pm
/etc/rc.d/init.d/virtualhosting restart
is wrong..
it should be stop and start
Locker
May 19th, 2009 at 3:32 pm
Good site, admin.
maxilo
September 22nd, 2009 at 8:55 pm
The best solution is to restore the damage from the database. With programs like AccessFIX can access database repair utility