Skip to content
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

Update migrations to follow team convention #330

Merged
merged 5 commits into from
Aug 3, 2023

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Aug 2, 2023

As a team, we have agreed that our convention when using arrow functions is to always wrap arguments in brackets even if there are only 1.

We spotted with a recent migration that we were not doing this. At the same time, we also clocked we were doing the following in some migrations.

exports.up = async function (knex) {
  await knex
    .schema

// vs

exports.down = function (knex) {
  return knex
    .schema

The Knex example implies what we are doing in down() is correct. Looking at some of our more straightforward migrations, for example, when creating schemas we saw that's what we were already doing.

As we tend to copy and paste previous migrations when adding new ones we've decided to correct what we have to save repeating the infractions in future changes!

As a team we have agreed that [our convention](https://github.com/DEFRA/water-abstraction-team/blob/main/coding_conventions.md#arrow-functions) when using arrow functions is to always wrap arguments in brackets even if there is only 1.

We spotted with a recent migration that we were not doing this. As we tend to copy and paste previous migrations when adding new ones we've decided to correct what we have to save repeating the infraction in future changes!
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Aug 2, 2023
@Cruikshanks Cruikshanks self-assigned this Aug 2, 2023
@Cruikshanks Cruikshanks marked this pull request as ready for review August 2, 2023 15:51
Jozzey
Jozzey previously approved these changes Aug 2, 2023
@Cruikshanks Cruikshanks removed the request for review from Beckyrose200 August 3, 2023 07:00
@Cruikshanks Cruikshanks marked this pull request as draft August 3, 2023 07:00
Note! Not all instances could be updated. There are times we are performing multiple calls in a migration therefore we do need to use async and await.

Also spotted some export.downs that were async but returning knex.schema() 🤦. Fixed those as well 😁
@Cruikshanks Cruikshanks marked this pull request as ready for review August 3, 2023 08:51
@Cruikshanks Cruikshanks requested a review from StuAA78 August 3, 2023 09:45
Copy link
Contributor

@Jozzey Jozzey left a comment

Choose a reason for hiding this comment

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

👍🏼

@Cruikshanks Cruikshanks merged commit ef25e9c into main Aug 3, 2023
@Cruikshanks Cruikshanks deleted the make-migrations-follow-convention branch August 3, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants