-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
This makes it easier to edit normally.
pkg/state/init.sql
Outdated
@@ -0,0 +1,340 @@ | |||
CREATE SCHEMA IF NOT EXISTS placeholder; | |||
|
|||
CREATE TABLE IF NOT EXISTS placeholder.migrations |
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.
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))) |
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.
We weren't using the output of pq.QuoteLiteral
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.
This looks good 👍
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 |
@andrew-farries PTAL |
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.