Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: syncdb not creating new table after dump is loaded
    primarykey
    data
    text
    <p>tl;dr: We want to add a new table to the database, without losing previous data.</p> <p>First we took a dump of the database using:</p> <pre><code>$ psql -h localhost dbname &gt; dump_file </code></pre> <p>Then we loaded it to our local db. This is working fine.</p> <p><strong>Problem starts:</strong> On adding a new model to models.py, syncdb doesn't create the table. However, if we create a new db (by deleting the data and running syncdb), it shows up as a created table.</p> <p>This is surprising, because we don't think that adding a new table is a 'schema migration' that syncdb cannot handle. Hence, we don't think South will help here.</p> <p>Is there something I'm missing/getting wrong?</p> <p>This is what our code looks like:</p> <pre><code>class Person(models.Model): # attributes class A(models.Model): # attributes class B(models.Model): a_fk = models.ForeignKey(A) # more attributes class ProblemModel(models.Model) p_fk = models.ForeignKey(Person) a_fk = models.ForeignKey(A) b_fk = models.ForeignKey(B) </code></pre> <p>The output for the concerned table using the command:</p> <pre><code>$ ./manage.py sqlall appname </code></pre> <p>is:</p> <pre><code>CREATE TABLE "appname_problemmodel" ( "id" serial NOT NULL PRIMARY KEY, "p_fk" integer NOT NULL REFERENCES "appname_person" ("p_fk") DEFERRABLE INITIALLY DEFERRED, "a_fk" integer NOT NULL REFERENCES "appname_a" ("id") DEFERRABLE INITIALLY DEFERRED, "b_fk" integer NOT NULL REFERENCES "appname_b" ("id") DEFERRABLE INITIALLY DEFERRED ) </code></pre> <p>Django version 1.5.1</p> <p>ProblemModel is the new model we're trying to add.</p> <p>Thanks in advance for the help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload