-
Notifications
You must be signed in to change notification settings - Fork 43
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
Dual write rule instances to new and old tables #3486
Changes from 1 commit
1aa28e6
63b9e40
5c2c810
7073b2d
78ee85b
035c705
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,20 @@ | ||
-- Copyright 2024 Stacklok, Inc | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
BEGIN; | ||
|
||
ALTER TABLE rule_instances ALTER COLUMN def DROP NOT NULL; | ||
ALTER TABLE rule_instances ALTER COLUMN params DROP NOT NULL; | ||
|
||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Copyright 2024 Stacklok, Inc | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
BEGIN; | ||
|
||
ALTER TABLE rule_instances ALTER COLUMN def SET NOT NULL; | ||
ALTER TABLE rule_instances ALTER COLUMN params SET NOT NULL; | ||
|
||
COMMIT; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ import ( | |
"strings" | ||
|
||
"github.com/google/uuid" | ||
"github.com/sqlc-dev/pqtype" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
"google.golang.org/protobuf/reflect/protoreflect" | ||
|
@@ -773,22 +772,14 @@ func upsertRuleInstances( | |
return nil, fmt.Errorf("unable to serialize rule params: %w", err) | ||
} | ||
|
||
newInstance := db.UpsertRuleInstanceParams{ | ||
id, err := qtx.UpsertRuleInstance(ctx, db.UpsertRuleInstanceParams{ | ||
ProfileID: profileID, | ||
RuleTypeID: entityRuleTuple.RuleID, | ||
Name: rule.Name, | ||
EntityType: entityType, | ||
Def: pqtype.NullRawMessage{ | ||
RawMessage: def, | ||
Valid: def != nil, | ||
}, | ||
Params: pqtype.NullRawMessage{ | ||
RawMessage: params, | ||
Valid: params != nil, | ||
}, | ||
} | ||
|
||
id, err := qtx.UpsertRuleInstance(ctx, newInstance) | ||
Def: def, | ||
Params: params, | ||
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. I assume that if there's no params defined then json.Marshall returns |
||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to insert new rule instance: %w", err) | ||
} | ||
|
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.
Since we haven't written anything to the columns, this is safe to do.