From 80164f7d19d3c71729bd77ba2de2a44aa1e1d3b8 Mon Sep 17 00:00:00 2001 From: Jorge Padilla Date: Wed, 13 Sep 2023 15:11:56 -0600 Subject: [PATCH] wip --- server/datastore/datastore_repository.go | 3 ++- server/migrations/33_add_composite_pkey.down.sql | 3 +++ server/migrations/33_add_composite_pkey.up.sql | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 server/migrations/33_add_composite_pkey.down.sql create mode 100644 server/migrations/33_add_composite_pkey.up.sql diff --git a/server/datastore/datastore_repository.go b/server/datastore/datastore_repository.go index d5f0df2d28..a9ed1c8b0e 100644 --- a/server/datastore/datastore_repository.go +++ b/server/datastore/datastore_repository.go @@ -91,7 +91,8 @@ func (r *Repository) Update(ctx context.Context, dataStore DataStore) (DataStore } defer tx.Rollback() - _, err = tx.ExecContext(ctx, deleteQuery, DataStoreSingleID) + query, params := sqlutil.Tenant(ctx, deleteQuery, DataStoreSingleID) + _, err = tx.ExecContext(ctx, query, params...) if err != nil { return DataStore{}, fmt.Errorf("datastore repository sql exec delete: %w", err) } diff --git a/server/migrations/33_add_composite_pkey.down.sql b/server/migrations/33_add_composite_pkey.down.sql new file mode 100644 index 0000000000..a9d31a009e --- /dev/null +++ b/server/migrations/33_add_composite_pkey.down.sql @@ -0,0 +1,3 @@ +ALTER TABLE data_stores +DROP CONSTRAINT data_stores_pkey, +ADD PRIMARY KEY (id); \ No newline at end of file diff --git a/server/migrations/33_add_composite_pkey.up.sql b/server/migrations/33_add_composite_pkey.up.sql new file mode 100644 index 0000000000..50be1e0988 --- /dev/null +++ b/server/migrations/33_add_composite_pkey.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE data_stores +DROP CONSTRAINT data_stores_pkey, +ADD PRIMARY KEY (id, tenant_id); \ No newline at end of file