Embed the new column according to the desired position in any table in the postgresql database.
It helps you to generate an sql script that looks for the dependencies of the table to be able to embed the new column, these dependencies are found recursively :-) Then recreate the table supporting you in the reconstruction of the original structure.
---- ----
| id | | id |
---- ----
---- ----
| c1 | | c1 |
---- ----
---- ---- ----
| c2 | |newc| |newc|
---- ---- ----
---- -> pgreshape (file.sql) -> ----
| c3 | offset = c1 | c2 |
---- ----
---- ----
| c4 | | c3 |
---- ----
----
| c4 |
----
Table dependencies | ||
Object | Support | Comments |
Columns | partial | |
ACL on Columns | complete | |
Comment | complete | |
Index | complete | |
Sequence | partial | |
Foreign Key | complete | |
Unique constraint | complete | |
Check constraint | complete | |
Exclude constraint | complete | |
Views recursive | complete | |
ACL on View | complete |
Global
$ git
$ gcc
$ cmake
$ make
Ubuntu 16.04 +
$ postgresql
$ postgresql-client
$ postgresql-contrib
$ postgresql-server-dev
$ libpq-dev
ArchLinux
$ postgresql
$ postgresql-libs
$ git clone https://github.com/rafaelsagastume/pgreshape.git
$ cd pgreshape
$ cmake .
$ make
$ sudo make install
$ git pull origin master
$ make clean && make
$ sudo make install
host = localhost
port = 5432
dbname = db1
user = postgres
password = 123
file = /tmp/file.sql
pgreshape -c /opt/reshape.conf -s rrhh -t expediente -offset emisor -column nueva -type 'boolean' -file /tmp/file-other.sql