Foreign key Rename does not generate SQL statements

PostgreSQL - related issues
Post Reply
greg
Posts: 3
Joined: Mon Feb 04, 2013 12:43 pm

Foreign key Rename does not generate SQL statements

Post by greg » Fri Feb 08, 2013 9:44 am

DbSchema 6.1.0 build 3716 and PostreSQL 9.2

When synchronizing Schema with Database and there is a foreign key to rename in database, DbSchema identifies it fine, but no SLQ statements is generated.
See attached screenshots.

Regards
Attachments
2.png
2.png (5.73 KiB) Viewed 7757 times
1.png
1.png (11.6 KiB) Viewed 7757 times

donose.mihai
Posts: 470
Joined: Thu Apr 07, 2011 11:05 am

Re: Foreign key Rename does not generate SQL statements

Post by donose.mihai » Mon Feb 11, 2013 9:08 am

Hello,

That's because the Foreign key rename sql has not been added yet to DbSchema, you can added manually from Databases -> Database Settings -> Stataments.

Recently we have added this option to DbSchema where each database can be customized and still we are adding new statements every day, can you give us an example how to rename a fk in postgres?

Regards,

Mihai
Attachments
2013-02-11_110519.png
2013-02-11_110519.png (56.46 KiB) Viewed 7751 times

greg
Posts: 3
Joined: Mon Feb 04, 2013 12:43 pm

Re: Foreign key Rename does not generate SQL statements

Post by greg » Thu Feb 14, 2013 4:34 pm

Hi,

The syntax is
ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ] RENAME CONSTRAINT constraint_name TO new_constraint_name
e.g. ALTER TABLE "sprPeripherals" RENAME CONSTRAINT "FK_sprPeriferals_sprStocks" TO "FK_sprPeripherals_sprStocks";
Supported from PostreSQL 9.2
http://www.postgresql.org/docs/9.2/inte ... table.html

Regards

Draco02
Posts: 1
Joined: Fri Mar 20, 2015 10:02 am

Re: Foreign key Rename does not generate SQL statements

Post by Draco02 » Fri Mar 20, 2015 10:05 am

Consequently, when the name of the table "tablename" is changed to, say, "newtablename", the name of sequence has to be changed to "newtablename_colname_seq". Otherwise newly created schema in database will have sequence "newtablename_colname_seq" (it is being created automatically by PostreSQL) while original schema will have sequence "tablename_colname_seq" and these two schemas will never be synchronized with .dbs file at once.

Post Reply