Skip to content

Commit

Permalink
fix demos
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Sep 18, 2023
1 parent 11f7acd commit be46e2a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
6 changes: 2 additions & 4 deletions server/config/demo/demo_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,15 @@ func (r *Repository) Create(ctx context.Context, demo Demo) (Demo, error) {
return Demo{}, fmt.Errorf("could not get JSON data from opentelemetry store example: %w", err)
}

tenantID := sqlutil.TenantID(ctx)

_, err = tx.ExecContext(ctx, insertQuery,
params := sqlutil.TenantInsert(ctx,
demo.ID,
demo.Name,
demo.Enabled,
demo.Type,
pokeshopJSONData,
openTelemetryStoreJSONData,
tenantID,
)
_, err = tx.ExecContext(ctx, insertQuery, params...)

if err != nil {
tx.Rollback()
Expand Down
13 changes: 13 additions & 0 deletions server/migrations/33_add_composite_pkey.down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ WHERE tenant_id = '';
ALTER TABLE data_stores ALTER COLUMN tenant_id TYPE uuid using tenant_id::uuid;


ALTER TABLE demos
DROP CONSTRAINT demos_pkey,
ADD PRIMARY KEY (id),
ALTER COLUMN tenant_id DROP DEFAULT,
ALTER COLUMN tenant_id DROP NOT NULL;

UPDATE demos
SET tenant_id = null
WHERE tenant_id = '';

ALTER TABLE demos ALTER COLUMN tenant_id TYPE uuid using tenant_id::uuid;


ALTER TABLE polling_profiles
DROP CONSTRAINT polling_profiles_pkey,
ADD PRIMARY KEY (id),
Expand Down
12 changes: 12 additions & 0 deletions server/migrations/33_add_composite_pkey.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ ADD PRIMARY KEY (id, tenant_id),
ALTER COLUMN tenant_id SET DEFAULT '';


ALTER TABLE demos ALTER COLUMN tenant_id TYPE varchar;

UPDATE demos
SET tenant_id = ''
WHERE tenant_id is null;

ALTER TABLE demos
DROP CONSTRAINT demos_pkey,
ADD PRIMARY KEY (id, tenant_id),
ALTER COLUMN tenant_id SET DEFAULT '';


ALTER TABLE polling_profiles ALTER COLUMN tenant_id TYPE varchar;

UPDATE polling_profiles
Expand Down

0 comments on commit be46e2a

Please sign in to comment.