title: Updating primary keys in POSTGRESQL
body: <p>I have a database from previous project that I want to use in another project, from security reasons I need to update the IDs of one of the table. Problem is that the table is heavily referenced by foreign keys from other tables: </p>
  
  <pre><code>CREATE TABLE "table_table" (
       "id" serial NOT NULL PRIMARY KEY,
       "created" timestamp with time zone NOT NULL,
  );
  
  
  CREATE TABLE "table_photo" (
       "id" serial NOT NULL PRIMARY KEY,
       "table_id" integer NOT NULL REFERENCES "table_table" ("id") DEFERRABLE INITIALLY DEFERRED,
  );
  </code></pre>
  
  <p>Now if I change the id on table_table the reference from table_photo won't work. 
  I will probably use something like this to change the IDs:</p>
  
  <pre><code>UPDATE table_table SET id = id + 15613;
  </code></pre>
  
  <p>I have read somewhere that I could use ON UPDATE CASCADE constraints to do this but I am not very sure how to use it. </p>
  
  <p>btw: I am using Django ORM.</p>