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

Extract initialisation SQL into separate file #435

Merged
merged 5 commits into from
Oct 28, 2024
Merged

Conversation

ryanslade
Copy link
Collaborator

@ryanslade ryanslade commented Oct 25, 2024

This makes it easier to edit normally.

I think we may want to pick a SQL formatter for this which we run automatically too.

It looks like prettier already has a SQL formatter so maybe we can just use that since we already use it to format the json schema.

This makes it easier to edit normally.
@@ -0,0 +1,340 @@
CREATE SCHEMA IF NOT EXISTS placeholder;

CREATE TABLE IF NOT EXISTS placeholder.migrations
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

placeholder will be replaced in code.

@@ -411,7 +71,8 @@ func (s *State) Init(ctx context.Context) error {
}

// Perform pgroll state initialization
_, err = tx.ExecContext(ctx, fmt.Sprintf(sqlInit, pq.QuoteIdentifier(s.schema), pq.QuoteLiteral(s.schema)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We weren't using the output of pq.QuoteLiteral

Copy link
Collaborator

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

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

This looks good 👍

I think we should also find a solution for SQL formatting, either as part of this PR or a follow up.

@ryanslade
Copy link
Collaborator Author

I think we should also find a solution for SQL formatting, either as part of this PR or a follow up.

I'll see if I can get it to use Prettier

@ryanslade
Copy link
Collaborator Author

@andrew-farries PTAL

@ryanslade ryanslade merged commit 88cc975 into main Oct 28, 2024
26 checks passed
@ryanslade ryanslade deleted the rs/embed-init-sql branch October 28, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants