Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const getGithubPullRequestIdType = async (knex) => {
const result = await knex("information_schema.columns")
.select("data_type")
.where({
table_schema: "public",
table_name: "github_pull_requests",
column_name: "id",
})
.first();

return result?.data_type ?? null;
};

export const up = async (knex) => {
const dataType = await getGithubPullRequestIdType(knex);

if (dataType === "bigint") {
return;
}

await knex.raw(
"ALTER TABLE github_pull_requests ALTER COLUMN id TYPE BIGINT",
);
Comment on lines +21 to +23
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type seems to be correct in production, so I don't understand the purpose of this PR. If it's in local just fix it.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prod database is good the migration file is not aligned. So when you apply db:drop + db:create + db:migrate:lastest, there is a drift that break the CI tests

};

export const down = async (knex) => {
const dataType = await getGithubPullRequestIdType(knex);

if (dataType === "integer") {
return;
}

await knex.raw(
"ALTER TABLE github_pull_requests ALTER COLUMN id TYPE INTEGER",
);
};
25 changes: 23 additions & 2 deletions apps/backend/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
-- PostgreSQL database dump
--

\restrict 2GIQSmC2cllwgA5SKtS5RhAwQOcUPaKxQ1gBkaPnM6Ir2Gz1OmHj6kk5YsYjXKG
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whta is this?


-- Dumped from database version 17.5
-- Dumped by pg_dump version 17.5 (Homebrew)
-- Dumped by pg_dump version 17.9 (Homebrew)

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -2671,6 +2673,22 @@ ALTER TABLE ONLY public.user_emails
ADD CONSTRAINT user_emails_pkey PRIMARY KEY (email);


--
-- Name: users users_email_unique; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.users
ADD CONSTRAINT users_email_unique UNIQUE (email);
Comment on lines +2680 to +2681
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that it was not present in the structure.



--
-- Name: users users_gitlabuserid_unique; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.users
ADD CONSTRAINT users_gitlabuserid_unique UNIQUE ("gitlabUserId");
Comment on lines +2688 to +2689
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this one but I checked in production and they are present so it's good to have them in the structure.



--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -3756,6 +3774,8 @@ ALTER TABLE ONLY public.users
-- PostgreSQL database dump complete
--

\unrestrict 2GIQSmC2cllwgA5SKtS5RhAwQOcUPaKxQ1gBkaPnM6Ir2Gz1OmHj6kk5YsYjXKG
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not generated in the dump


-- Knex migrations

INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20161217154940_init.js', 1, NOW());
Expand Down Expand Up @@ -3937,4 +3957,5 @@ INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('2026021
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20260216200736_enforce-sso.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20260219170000_project-auto-ignore.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20260222100000_team-saml-expiration-check.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20260328120000_build-merge-queue-gh-pull-requests.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20260328120000_build-merge-queue-gh-pull-requests.js', 1, NOW());
INSERT INTO public.knex_migrations(name, batch, migration_time) VALUES ('20260402112104_update-github-pull-request-id-type.js', 1, NOW());
Loading