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

chore: style sql #277

Merged
merged 2 commits into from
Nov 15, 2023
Merged

chore: style sql #277

merged 2 commits into from
Nov 15, 2023

Conversation

chris13524
Copy link
Member

@chris13524 chris13524 commented Nov 13, 2023

Description

Make SQL style consistent. While it's generally a bad idea to change existing migrations, these should be functionally equivalent and won't be rerun anyway because the migration ID is what determines if the migration was already run or not.

This PR matches notify-server styling and has a companion PR here.

This style matches what I've generally seen in the Postgres documentation:

  • lowercase type names
  • capital constraint names (sometimes I see lowercase, but uppercase seems more common)
  • capital ARRAY
  • opening parenthesis on same line
  • 4 space indents
  • space between the constraint name and the columns it applies to e.g. UNIQUE (device_token)

Also as a personal preference:

  • no IF NOT EXISTS for table creation as these are migrations, and shouldn't exist anyway (and if they do, there is a potential for being out of sync)
  • generally have newlines between each statement
  • trailing newlines at end of file

How Has This Been Tested?

Not tested

Due Diligence

  • Breaking change
  • Requires a documentation update
  • Requires a e2e/integration test update

@chris13524 chris13524 self-assigned this Nov 13, 2023
@arein arein added the accepted The issue has been accepted into the project label Nov 13, 2023
@chris13524 chris13524 changed the title Chore/style sql chore: style sql Nov 13, 2023
Copy link
Member

@arein arein left a comment

Choose a reason for hiding this comment

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

Sweet - FYI in other repos we use sqlfluff for this - it's an awesome tool

@chris13524
Copy link
Member Author

@arein nice! We should pull in something like this. Would be nice if it had a brew install though

@chris13524 chris13524 merged commit 70dad11 into main Nov 15, 2023
10 checks passed
@chris13524 chris13524 deleted the chore/style-sql branch November 15, 2023 20:07
chris13524 added a commit that referenced this pull request Nov 15, 2023
chris13524 added a commit that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue has been accepted into the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants