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

  • Home
  • SEARCH
  • 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 9118489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:09:59+00:00 2026-06-17T05:09:59+00:00

I migrated my database from MySql to PostgreSQL, and, as I noticed that many

  • 0

I migrated my database from MySql to PostgreSQL, and, as I noticed that many tables weren’t updated, some googling told me to do things like this:

ALTER SEQUENCE my_table_id_seq OWNED BY my_table.id;

and things started to work. I had to do this for all my tables.

Then I realized that after creating a django.contrib.auth.model.User, and trying to create a UserProfile afterwards with a post_save hook, I would get an IntegrityError because the user_id foreign key is sent as null.

Here’s the query and args (in Python) that is sent to PostgreSQL:

INSERT INTO "auth_user" ("username", "first_name", "last_name", "email", "password", "is_staff", "is_active", "is_superuser", "last_login", "date_joined") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) (u'apitest04', '', '', u'a@a.aa', 'sha1$9f796$69c88c635c8a53a91544765d7996747cf326cfec', False, True, False, u'2013-01-05 12:39:07.384198', u'2013-01-05 12:39:07.384198')

INSERT INTO "myapp_userprofile" ("user_id", "website", "job", "hobbies", "timezone", "about", "company_name", "company_description", "company_website", "retailer_country", "avatar", "default_license", "default_watermark_text", "default_watermark", "default_watermark_position", "default_watermark_opacity", "language") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) (None, None, None, None, None, None, None, None, None, None, None, 0, None, False, 0, 10, None)

I suppose what’s happening is that the sequence id for auth_user is not advanced before the transaction is closed. I suspect that because the creation of the User is rolled back when the creation of the UserProfile fails, so they must be happening during the same transaction.

Is it possible that the id of the User is somehow not returned yet, because the transaction has not ended yet? And how do you propose I fix the problem?

  • 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-17T05:10:00+00:00Added an answer on June 17, 2026 at 5:10 am

    The problem is solved, and it was happening because the auth_user.id sequence had no owner. This fixed it:

    ALTER SEQUENCE auth_auth_id_seq OWNED BY auth_auth.id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that I migrated from MySql using SQL Server Migration Assistant
I recently migrated a database from mysql to pgsql 9. But now when I
I have changed database from postgresql to mysql , but I don't know how
I'm one of those that recently decided to migrate from MySQL to PostgreSQL and
I've migrated a database from mysql to SQL Server (politics), original mysql database using
I should migrate my database from mysql to oracle, My problem is that my
I need to migrate some data from one MYSQL database to another but the
I've migrated my database on my mobile device away from VistaDB because it's just
I'm writing a .NET command-line application that will migrate users from an existing database
I'm new to Postgresql and I'm trying to migrate my application from MySQL. I

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.