-
Notifications
You must be signed in to change notification settings - Fork 49
feat(migration): add migration to update github_pull_requests.id type to bigint #2086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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", | ||
| ); | ||
| }; | ||
|
|
||
| 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", | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,10 @@ | |
| -- PostgreSQL database dump | ||
| -- | ||
|
|
||
| \restrict 2GIQSmC2cllwgA5SKtS5RhAwQOcUPaKxQ1gBkaPnM6Ir2Gz1OmHj6kk5YsYjXKG | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| -- | ||
|
|
@@ -3756,6 +3774,8 @@ ALTER TABLE ONLY public.users | |
| -- PostgreSQL database dump complete | ||
| -- | ||
|
|
||
| \unrestrict 2GIQSmC2cllwgA5SKtS5RhAwQOcUPaKxQ1gBkaPnM6Ir2Gz1OmHj6kk5YsYjXKG | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is that?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
|
|
@@ -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()); | ||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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