eulerto / pgquarrel

pgquarrel compares PostgreSQL database schemas (DDL)
BSD 3-Clause "New" or "Revised" License
390 stars 42 forks source link

solve issue #61, respect the original order of the columns at the time the table is created #73

Closed rafaelsagastume closed 4 years ago

rafaelsagastume commented 4 years ago

Good afternoon, Euler @eulerto

A pleasure to greet you again, a pull request has been created that solves the order of the columns of a source table when it will be created in target table, the columns are sorted by pg_attribute with the attnum field, solve issue #61.

source table

CREATE TABLE auth.menu ( id integer NOT NULL DEFAULT nextval('auth.menu_id_seq'::regclass), id_role integer NOT NULL, name character varying(100) NOT NULL, route character varying(50) NOT NULL, icon character varying(50) NOT NULL, sort integer NOT NULL, description character varying(255) NOT NULL, is_active boolean NOT NULL DEFAULT true, id_previous integer )

target table

CREATE TABLE auth.menu ( id integer DEFAULT nextval('auth.menu_id_seq'::regclass) NOT NULL, id_role integer NOT NULL, name character varying(100) NOT NULL, route character varying(50) NOT NULL, icon character varying(50) NOT NULL, sort integer NOT NULL, description character varying(255) NOT NULL, is_active boolean DEFAULT true NOT NULL, id_previous integer );

As I always hope you like the solution, I am open to any feedback

eulerto commented 4 years ago

@rafaelsagastume did you check my comment in issue #61 ? pgquarrel needs to preserve columns order by name because it use it to compare columns. There should be a mechanism to order PQLAttribute by attnum or name then it is easy to print columns using attnum order.

rafaelsagastume commented 4 years ago

@rafaelsagastume did you check my comment in issue #61 ? pgquarrel needs to preserve columns order by name because it use it to compare columns. There should be a mechanism to order PQLAttribute by attnum or name then it is easy to print columns using attnum order.

@eulerto , Now I realize, what I understand is to do the sorting after processing all the comparisons a moment before generating the sql script, I don't know if I get the correct message.