check_postgres icon indicating copy to clipboard operation
check_postgres copied to clipboard

same_schema gets confused if constraints are not uniquely named

Open richyen opened this issue 10 years ago • 0 comments

If I have different constraints for two tables, but they have the same name, the --same_schema action will mix them up between the two databases (especially if one database is v. 8.4.x and the other database is v. 9.2.x):

EXAMPLE 1: Constraint "public.min_password_length_check": "conkey" is different: Database 1: {2} Database 2: {6} "consrc" is different: Database 1: (length((join_password)::text) >= 4) Database 2: (length((enrollment_password)::text) >= 4) "tname" is different: Database 1: table_1 Database 2: table_2

-- table_1 definition: Table "public.table_1" Column | Type | Modifiers ---------------------+-----------------------+------------------------ id | integer | not null join_password | character varying(12) | not null lock_prefs | boolean | not null default false lock_dates | boolean | not null default false lock_info | boolean | not null default false allow_sec_assign | boolean | not null default true lock_s_view_reports | boolean | not null default false Indexes: "table_1_pkey" PRIMARY KEY, btree (id) Check constraints: "min_password_length_check" CHECK (length(join_password::text) >= 4) Foreign-key constraints:

-- table_2 definition: Table "public.table_2" Column | Type | Modifiers
-------------------------+--------------------------+-------------------------------------------------------------- id | integer | not null default nextval(('table_2_id_seq'::text)::regclass) class_type | smallint | not null title | character varying(100) | not null class_number | character varying(50) | description | character varying(1000) | enrollment_password | character varying(12) | not null state_flag | smallint | not null default 10 date_lastmodified | timestamp with time zone | not null default now() date_setup | timestamp with time zone | not null default ('now'::text)::date date_start | timestamp with time zone | not null date_end | timestamp with time zone | not null term_length | interval | not null default '5 years'::interval remoteaddr | inet | not null class_homepage_name | character varying(50) | class_homepage_url | character varying(200) | max_file_size | integer | not null default 20971520 max_paper_length | integer | not null default 1000000 grading_scale_slot | smallint | not null default 0 scale_owner | integer | products_enabled | integer | not null default 1535 s_view_reports | boolean | not null default false s_submit_topics | boolean | not null default true account | integer | not null user | integer | drop_lowest_grade | boolean | not null default false source | smallint | not null default 0 s_view_user_email | boolean | not null default true max_portfolio_file_size | integer | native_locked | boolean | not null default false Indexes: "table_2_pkey" PRIMARY KEY, btree (id) "table_2_account_idx" btree (account) "table_2_user_idx" btree (user) Check constraints: "min_password_length_check" CHECK (length(enrollment_password::text) >= 4) Foreign-key constraints:

EXAMPLE 2: Constraint "public.$1": "confdeltype" is different: Database 1: a Database 2:
"conffeqop" is different: Database 1: {96} Database 2: "confkey" is different: Database 1: {1} Database 2: "confmatchtype" is different: Database 1: u Database 2:
"confupdtype" is different: Database 1: a Database 2:
"conkey" is different: Database 1: {2} Database 2: {2,3} "conpfeqop" is different: Database 1: {96} Database 2: "conppeqop" is different: Database 1: {96} Database 2: "consrc" is different: Database 1: Database 2: (start_date <= end_date) "contype" is different: Database 1: f Database 2: c "tname" is different: Database 1: table_3 Database 2: table_4

--table_3 definition: Table "public.table_3" Column | Type | Modifiers
--------------------+--------------------------+-------------------------------------------------------- id | integer | not null default nextval('table_3_id_seq'::regclass) source | integer | not null reader | integer | not null grading_group | integer | grade | smallint | score | smallint | read_comment | text | read_type | integer | not null date_submitted | timestamp with time zone | duration | interval | default '00:00:00'::interval delete_flag | boolean | not null default false outlying | boolean | not null default false needs_arbiter | boolean | not null default false summary | text | last_saved | timestamp with time zone | default now() date_created | timestamp with time zone | default now() pm_review_set | integer | not null default (-1) last_gm_version | character varying(10) | not null default 'abc2'::character varying user_view_first | timestamp with time zone | user_view_last | timestamp with time zone | user_view_count | integer | updated_via_ios | boolean | default false Indexes: Foreign-key constraints: "$1" FOREIGN KEY (source) REFERENCES table_x(id) "$2" FOREIGN KEY (reader) REFERENCES table_y(id) "$4" FOREIGN KEY (read_type) REFERENCES table_3_type(id) "table_3_other_table_fkey" FOREIGN KEY (other_table) REFERENCES table_z(id)

--table_4 definition: Table "public.table_4" Column | Type | Modifiers
---------------+-----------------------------+------------------------------------------------------------- id | integer | not null default nextval('table_4_id_seq'::regclass) start_date | timestamp without time zone | not null default ('now'::text)::date end_date | timestamp without time zone | not null priority | smallint | not null account_types | smallint | not null platform | smallint | not null content | text | not null max_views | smallint | not null default 1 type | integer | not null default 1 header | text | link_url | text | Indexes: Check constraints: "$1" CHECK (start_date <= end_date) Foreign-key constraints: "$2" FOREIGN KEY (priority) REFERENCES table_4_priority(id) "$3" FOREIGN KEY (account_types) REFERENCES table_4_group(id) "$4" FOREIGN KEY (platform) REFERENCES table_4_platform(id) "type_fkey" FOREIGN KEY (type) REFERENCES table_4_type(id) ON DELETE CASCADE Referenced by:

richyen avatar Mar 21 '14 17:03 richyen