Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d90bbb4
chore: update environment_id value
Ubisoft-potato Aug 28, 2024
1ca796a
feat: account module
Ubisoft-potato Aug 28, 2024
ea7c451
feat: migrate from environment_namespace to environment_id
Ubisoft-potato Sep 3, 2024
5816380
feat: ui proto
Ubisoft-potato Sep 3, 2024
7daf8de
fix: lint and test
Ubisoft-potato Sep 3, 2024
bb10c99
fix: lint and test
Ubisoft-potato Sep 3, 2024
f01dbfe
fix: auditlog test
Ubisoft-potato Sep 3, 2024
6766d15
test: environment_id
Ubisoft-potato Sep 4, 2024
023d8e1
chore: remove proto environment_namespace
Ubisoft-potato Sep 4, 2024
1bf4c1c
chore: fronted proto
Ubisoft-potato Sep 4, 2024
679462f
chore: console migrate environmentId
Ubisoft-potato Sep 4, 2024
ba70324
chore: function params
Ubisoft-potato Sep 4, 2024
eccedeb
chore: update environment_namespace migration
Ubisoft-potato Sep 5, 2024
e6b6170
fix: ops_progressive_rollout sql
Ubisoft-potato Sep 5, 2024
efb91fa
chore: hack script
Ubisoft-potato Sep 5, 2024
8e61670
chore: bq column
Ubisoft-potato Sep 10, 2024
f794d32
chore: update atlas migration file
Ubisoft-potato Nov 1, 2024
4cee39b
chore: environment_id field
Ubisoft-potato Nov 1, 2024
b0df5f6
chore: feature sql
Ubisoft-potato Nov 1, 2024
22696df
chore: ui proto
Ubisoft-potato Nov 1, 2024
db707da
chore: sql
Ubisoft-potato Nov 1, 2024
154f1f7
chore: environment_namespace default empty
Ubisoft-potato Nov 1, 2024
f8d6e95
chore: remove where condition
Ubisoft-potato Nov 1, 2024
e1baefc
chore: update migration
Ubisoft-potato Nov 1, 2024
916509a
feat: online DDL
Ubisoft-potato Nov 6, 2024
d9d944e
chore: online DDL
Ubisoft-potato Nov 6, 2024
469e566
chore: rebase main
Ubisoft-potato Nov 12, 2024
f918816
chore: split migration file
Ubisoft-potato Nov 13, 2024
a44b805
chore: remove migration file
Ubisoft-potato Nov 13, 2024
4a0eaed
chore: add back reverted migration files
Ubisoft-potato Nov 13, 2024
913e4e7
chore: update hash
Ubisoft-potato Nov 13, 2024
a058d9c
chore: rebase main
Ubisoft-potato Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions api-description/apidocs.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,9 @@ definitions:
type: string
event:
$ref: '#/definitions/protobufAny'
environmentNamespace:
environmentId:
type: string
description: SDK doens't need to set this field. It's set by gateway service.
description: service.
clientSourceId:
type: string
enum:
Expand Down
16 changes: 7 additions & 9 deletions api-description/web-api.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,7 @@ definitions:
type: string
command:
$ref: '#/definitions/accountChangeAPIKeyNameCommand'
environmentNamespace:
environmentId:
type: string
accountChangeAPIKeyNameResponse:
type: object
Expand Down Expand Up @@ -2987,7 +2987,7 @@ definitions:
properties:
command:
$ref: '#/definitions/accountCreateAPIKeyCommand'
environmentNamespace:
environmentId:
type: string
accountCreateAPIKeyResponse:
type: object
Expand Down Expand Up @@ -3113,7 +3113,7 @@ definitions:
type: string
command:
$ref: '#/definitions/accountDisableAPIKeyCommand'
environmentNamespace:
environmentId:
type: string
accountDisableAPIKeyResponse:
type: object
Expand Down Expand Up @@ -3142,7 +3142,7 @@ definitions:
type: string
command:
$ref: '#/definitions/accountEnableAPIKeyCommand'
environmentNamespace:
environmentId:
type: string
accountEnableAPIKeyResponse:
type: object
Expand All @@ -3165,8 +3165,6 @@ definitions:
accountEnvironmentAPIKey:
type: object
properties:
environmentNamespace:
type: string
apiKey:
$ref: '#/definitions/accountAPIKey'
environmentDisabled:
Expand Down Expand Up @@ -3198,7 +3196,7 @@ definitions:
properties:
id:
type: string
environmentNamespace:
environmentId:
type: string
accountGetAPIKeyResponse:
type: object
Expand Down Expand Up @@ -3268,8 +3266,6 @@ definitions:
format: int64
cursor:
type: string
environmentNamespace:
type: string
orderBy:
$ref: '#/definitions/accountListAPIKeysRequestOrderBy'
orderDirection:
Expand All @@ -3278,6 +3274,8 @@ definitions:
type: string
disabled:
type: boolean
environmentId:
type: string
accountListAPIKeysRequestOrderBy:
type: string
enum:
Expand Down
2 changes: 1 addition & 1 deletion hack/create-api-key/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *command) Run(ctx context.Context, metrics metrics.Metrics, logger *zap.
Name: *c.name,
Role: accountproto.APIKey_Role(role),
},
EnvironmentNamespace: *c.environmentNamespace,
EnvironmentId: *c.environmentNamespace,
})
if err != nil {
logger.Error("Failed to create api key", zap.Error(err))
Expand Down
4 changes: 2 additions & 2 deletions hack/create-big-query-table/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *command) Run(ctx context.Context, metrics metrics.Metrics, logger *zap.
// Create tables
evaluationEventSchema := bigquery.Schema{
{Name: "id", Type: bigquery.StringFieldType},
{Name: "environment_namespace", Type: bigquery.StringFieldType},
{Name: "environment_id", Type: bigquery.StringFieldType},
{Name: "timestamp", Type: bigquery.TimestampFieldType},
{Name: "feature_id", Type: bigquery.StringFieldType},
{Name: "feature_version", Type: bigquery.IntegerFieldType},
Expand All @@ -85,7 +85,7 @@ func (c *command) Run(ctx context.Context, metrics metrics.Metrics, logger *zap.
}
goalEventSchema := bigquery.Schema{
{Name: "id", Type: bigquery.StringFieldType},
{Name: "environment_namespace", Type: bigquery.StringFieldType},
{Name: "environment_id", Type: bigquery.StringFieldType},
{Name: "timestamp", Type: bigquery.TimestampFieldType},
{Name: "goal_id", Type: bigquery.StringFieldType},
{Name: "value", Type: bigquery.FloatFieldType},
Expand Down
4 changes: 2 additions & 2 deletions hack/delete-e2e-data-mysql/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (c *command) constructDeleteQuery(target *mysqlE2EInfo) (query string, args
DELETE FROM
%s
WHERE
environment_namespace = ? AND
environment_id = ? AND
%s LIKE ?
`, target.table, target.targetField)
args = []interface{}{
Expand All @@ -154,7 +154,7 @@ func (c *command) constructDeleteQuery(target *mysqlE2EInfo) (query string, args
DELETE FROM
%s
WHERE
environment_namespace = ?
environment_id = ?
`, target.table)
args = []interface{}{
envNamespace,
Expand Down
2 changes: 1 addition & 1 deletion manifests/bucketeer/charts/api/values.yaml

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions manifests/bucketeer/charts/web/values.yaml

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions migration/mysql/20241113142932_update_environment_id_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
-- Step 1: Drop all foreign keys referencing environment_namespace
ALTER TABLE auto_ops_rule DROP FOREIGN KEY foreign_auto_ops_rule_feature_id_environment_namespace;
ALTER TABLE experiment DROP FOREIGN KEY foreign_experiment_feature_id_environment_namespace;
ALTER TABLE ops_count
DROP FOREIGN KEY foreign_ops_count_feature_id_environment_namespace,
DROP FOREIGN KEY foreign_ops_count_auto_ops_rule_id_environment_namespace;
ALTER TABLE ops_progressive_rollout DROP FOREIGN KEY foreign_progressive_rollout_feature_id_environment_namespace;
ALTER TABLE flag_trigger DROP FOREIGN KEY foreign_flag_trigger_feature_id_environment_namespace;
ALTER TABLE segment_user DROP FOREIGN KEY foreign_segment_user_segment_id_environment_namespace;

-- Step 2: Populate environment_id with values from environment_namespace
UPDATE feature SET environment_id = environment_namespace;
UPDATE account SET environment_id = environment_namespace;
UPDATE api_key SET environment_id = environment_namespace;
UPDATE audit_log SET environment_id = environment_namespace;
UPDATE auto_ops_rule SET environment_id = environment_namespace;
UPDATE experiment SET environment_id = environment_namespace;
UPDATE experiment_result SET environment_id = environment_namespace;
UPDATE feature_last_used_info SET environment_id = environment_namespace;
UPDATE flag_trigger SET environment_id = environment_namespace;
UPDATE goal SET environment_id = environment_namespace;
UPDATE mau SET environment_id = environment_namespace;
UPDATE ops_count SET environment_id = environment_namespace;
UPDATE ops_progressive_rollout SET environment_id = environment_namespace;
UPDATE push SET environment_id = environment_namespace;
UPDATE segment SET environment_id = environment_namespace;
UPDATE segment_user SET environment_id = environment_namespace;
UPDATE subscription SET environment_id = environment_namespace;
UPDATE tag SET environment_id = environment_namespace;

-- Step 3: Change PRIMARY KEY to use environment_id instead of environment_namespace
ALTER TABLE feature_last_used_info
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE mau
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (user_id, yearmonth, source_id, environment_id);

ALTER TABLE ops_count
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE ops_progressive_rollout
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE segment_user
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE feature
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE account
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE api_key
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE audit_log
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE auto_ops_rule
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE experiment
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE experiment_result
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE flag_trigger
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE goal
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE push
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE segment
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE subscription
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);

ALTER TABLE tag
ALGORITHM=INPLACE,
DROP PRIMARY KEY,
ADD PRIMARY KEY (id, environment_id);
3 changes: 2 additions & 1 deletion migration/mysql/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:OJvYQmdFDLoyPO32FuZtV3/wh6AE6KcLRc7Y+jadtE8=
h1:V8cRpgqJinbttzFCPGa+rbd3Zrm6BGsTB0w58QlTuVs=
20240626022133_initialization.sql h1:u9qmPkwWX7PN92qEcDDfR92lrMpwadQSMxUJgv6LjQ0=
20240708065726_update_audit_log_table.sql h1:k7gK8Njv1yHMsYXAQtSgMaSbXy4lxyZ9MPzbJyMyyoM=
20240815043128_update_auto_ops_rule_table.sql h1:6ib+XfS1uu9AUO3qESvkpUfOu3qUsLwHm9KHcrGEz0E=
Expand All @@ -11,3 +11,4 @@ h1:OJvYQmdFDLoyPO32FuZtV3/wh6AE6KcLRc7Y+jadtE8=
20241028031327_add_org_url_unique.sql h1:Xn0Pilm+RRseqZZXdsIdXulwy+R69xIC6ygA8MD19CM=
20241029011618_update_account_v2_table.sql h1:vcQDt2A4WdC0DP/SdZNjsl/T4oVrIVITgPRgc773Hn4=
20241113125451_update_environment_namespace.sql h1:dqTCT/L3QtjMIsM788jAisRiDU0ItEx4m3xgOiuXU1k=
20241113142932_update_environment_id_table.sql h1:MufoP4KqI2pl8lCV5OHhyITYC+VQcYJc3jSwDpqK0Ks=
12 changes: 6 additions & 6 deletions pkg/account/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ func (s *AccountService) checkSystemAdminRole(
func (s *AccountService) checkEnvironmentRole(
ctx context.Context,
requiredRole proto.AccountV2_Role_Environment,
environmentNamespace string,
environmentId string,
localizer locale.Localizer,
) (*eventproto.Editor, error) {
editor, err := role.CheckEnvironmentRole(
ctx,
requiredRole,
environmentNamespace,
environmentId,
func(email string) (*proto.AccountV2, error) {
account, err := s.getAccountV2ByEnvironmentID(ctx, email, environmentNamespace, localizer)
account, err := s.getAccountV2ByEnvironmentID(ctx, email, environmentId, localizer)
if err != nil {
return nil, err
}
Expand All @@ -285,7 +285,7 @@ func (s *AccountService) checkEnvironmentRole(
"Unauthenticated",
log.FieldsFromImcomingContext(ctx).AddFields(
zap.Error(err),
zap.String("environmentNamespace", environmentNamespace),
zap.String("environmentId", environmentId),
)...,
)
dt, err := statusUnauthenticated.WithDetails(&errdetails.LocalizedMessage{
Expand All @@ -301,7 +301,7 @@ func (s *AccountService) checkEnvironmentRole(
"Permission denied",
log.FieldsFromImcomingContext(ctx).AddFields(
zap.Error(err),
zap.String("environmentNamespace", environmentNamespace),
zap.String("environmentId", environmentId),
)...,
)
dt, err := statusPermissionDenied.WithDetails(&errdetails.LocalizedMessage{
Expand All @@ -317,7 +317,7 @@ func (s *AccountService) checkEnvironmentRole(
"Failed to check role",
log.FieldsFromImcomingContext(ctx).AddFields(
zap.Error(err),
zap.String("environmentNamespace", environmentNamespace),
zap.String("environmentId", environmentId),
)...,
)
dt, err := statusInternal.WithDetails(&errdetails.LocalizedMessage{
Expand Down
Loading
Loading