0

I have created a db long ago using django. Now as we are migrating the application, so I need all the CREATE TABLE sql queries which django might have run to create the entire db for our service (which has around 70-80 tables and each table has avg 30-70 columns).

Both the servers old and new are using Postgres for databases.

But the technology stack is completely different (A 3rd party proprietary application which will host the service) instead of django.

If I start to write all the tables again from scratch, it will take at least a week or two.

Is there any way either from Postgres or from django which can generate the CREATE TABLE sql schema for an entire db keeping all the relationship as is?

Also, I have to do minor modification to that schema as per customer requirement.

p.s - pg_dump won't work as I need actual schema itself to get it reviewed from client.

Laxmikant
  • 2,046
  • 3
  • 30
  • 44
  • 1
    `pg_dump` **will** give you the "actual" schema –  Feb 25 '20 at 12:46
  • "*If I start to write all the tables again from scratch, it will take at least a week or two*" - that's why the `CREATE TABLE` statements should be treated the same as Python source code and all the SQL scripts (for creation and migration) should be stored in the version control system alongside the actual application code –  Feb 25 '20 at 12:49
  • @a_horse_with_no_name - oh, is it? Let me try. Thanks – Laxmikant Feb 25 '20 at 12:49
  • @a_horse_with_no_name-yeah but the django doesn't directly treat it as Application code as it uses classes for tables and `class variables` as columns. It fully focuses on ORM. Hence the problem occurred. – Laxmikant Feb 25 '20 at 12:52

0 Answers0