filecoin-project / filplus-backend

Other
2 stars 1 forks source link

Issue modification creates an application if do not exist #217

Closed Filip-L closed 1 month ago

Filip-L commented 1 month ago

Issue modification creates an application if do not exist

Description: From now on, creating an application during issue modification is possible if it does not already exist.

A new field, issue_number, of type bigint, has been added to the database. This field will be used to check if an application already exists for an issue.

A new unique index has been added to the database. This index ensures that an application cannot be created if one already exists with the same combination of repo, owner, pr_number, and issue_number.

Deployment Considerations:

Ensure that SQL code from migration files is executed in the exact order specified to avoid issues and maintain database integrity.

SQL code to execute on the applications table:

ALTER TABLE applications
    ADD COLUMN "issue_number" bigint;

UPDATE applications SET issue_number = (application::json->>'Issue Number')::bigint;

ALTER TABLE applications
    ALTER COLUMN issue_number SET NOT NULL;

CREATE UNIQUE INDEX application_owner_repo_issue_number_pr_number
ON applications USING btree
(owner, repo, issue_number, pr_number);