Search
 
SCRIPT & CODE EXAMPLE
 

SQL

duplicate key value violates unique constraint "django_admin_log_pkey"

-- Enter the DB shell with `./manage.py dbshell`

-- Get latest ID
SELECT id FROM "django_admin_log" ORDER BY id DESC LIMIT 1;

-- Set the next value of the ID sequence to the result of the first query + 1
SELECT setval('django_admin_log_id_seq', LASTID + 1);

-- (replace `LASTID` with the result of the first query)
Comment

duplicate key value violates unique constraint "django_migrations_pkey"

from django.db import connections

query = "SELECT setval('django_migrations_id_seq', (SELECT MAX(id) FROM django_migrations))"
cursor = connections['default'].cursor()
cursor.execute(query) 
row = cursor.fetchone()
Comment

PREVIOUS NEXT
Code Example
Sql :: update query in sql 
Sql :: sql server get date of previous sunday 
Sql :: SQL IN Operator With Subquery 
Sql :: java.sql.sqlexception: the url cannot be null 
Sql :: mysql dump structure only 
Sql :: mysql delet from the child table when we delete the rows from the parent 
Sql :: SQL Server date literal 
Sql :: order by in codeigniter query builder 
Sql :: sql average 
Sql :: mysql copy row with new id 
Sql :: learn sql 
Sql :: mysql in clausule string array 
Sql :: mysql set column equal to another automatic 
Sql :: Can you Join two Tables With Common Column? 
Sql :: sql subquery 
Sql :: windows could not start the sql server on local computer 
Sql :: sql recherche nom prenom 
Sql :: mysql shell set time_zone 
Sql :: mysql foreign key 
Sql :: if exist column in table drop sql query mysql 
Sql :: Join multiple table by MySQL 
Sql :: sql update from one table to another based on a id match 
Sql :: doctors appointment 
Sql :: stuff and replace in sql 
Sql :: is firebase nosql 
Sql :: create view in oracle sql 
Sql :: postgresql gset 
Sql :: get relation data in mysql using query to excel 
Sql :: delete from table and truncate table 
Sql :: recursive stored procedure in sql server 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =