Changed to rely on default constraint names in database types instead of overriding it
Motivation
GORM apparently got confused when we specified the foreign key column name. It wrongly associated the Token.TokenID column instead of the Project.TokenID and Provider.TokenID etc.
This whole confusion seems to be because GORM was updated between wharf-api v5.0.0 and v5.1.0.
My love for GORM is decreasing more and more as time goes on. It's overall just quite unstable in its behaviour. This fight about foreign key constraint names we've fought before in a previous update. Now we tackle it again.
Before
$ \d token
Table "public.token"
Column | Type | Collation | Nullable | Default
------------+--------------------------+-----------+----------+-----------------------------------------
created_at | timestamp with time zone | | |
updated_at | timestamp with time zone | | |
token_id | bigint | | not null | nextval('token_token_id_seq'::regclass)
value | character varying(500) | | not null |
user_name | character varying(500) | | not null | ''::character varying
Indexes:
"token_pkey" PRIMARY KEY, btree (token_id)
Foreign-key constraints:
"fk_branch_token" FOREIGN KEY (token_id) REFERENCES branch(branch_id) ON UPDATE RESTRICT ON DELETE RESTRICT
"fk_project_token" FOREIGN KEY (token_id) REFERENCES project(project_id) ON UPDATE RESTRICT ON DELETE RESTRICT
"fk_provider_token" FOREIGN KEY (token_id) REFERENCES provider(provider_id) ON UPDATE RESTRICT ON DELETE RESTRICT
After
$ \d token
Table "public.token"
Column | Type | Collation | Nullable | Default
------------+--------------------------+-----------+----------+-----------------------------------------
created_at | timestamp with time zone | | |
updated_at | timestamp with time zone | | |
token_id | bigint | | not null | nextval('token_token_id_seq'::regclass)
value | character varying(500) | | not null |
user_name | character varying(500) | | not null | ''::character varying
Indexes:
"token_pkey" PRIMARY KEY, btree (token_id)
Referenced by:
TABLE "branch" CONSTRAINT "fk_branch_token" FOREIGN KEY (token_id) REFERENCES token(token_id) ON UPDATE RESTRICT ON DELETE RESTRICT
TABLE "project" CONSTRAINT "fk_project_token" FOREIGN KEY (token_id) REFERENCES token(token_id) ON UPDATE RESTRICT ON DELETE RESTRICT
TABLE "provider" CONSTRAINT "fk_provider_token" FOREIGN KEY (token_id) REFERENCES token(token_id) ON UPDATE RESTRICT ON DELETE RESTRICT
"Referenced by" instead of its own "Foreign-key constraints". Much better
CHANGELOG.md
file, according to docs: https://iver-wharf.github.io/#/development/changelogs/writing-changelogsSummary
Motivation
GORM apparently got confused when we specified the foreign key column name. It wrongly associated the
Token.TokenID
column instead of theProject.TokenID
andProvider.TokenID
etc.This whole confusion seems to be because GORM was updated between wharf-api v5.0.0 and v5.1.0.
My love for GORM is decreasing more and more as time goes on. It's overall just quite unstable in its behaviour. This fight about foreign key constraint names we've fought before in a previous update. Now we tackle it again.
Before
After
"Referenced by" instead of its own "Foreign-key constraints". Much better