Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update instance index (#5845)

Danny Xu29970058ff91
diff --git a/backend/migrator/migration/dev/LATEST.sql b/backend/migrator/migration/dev/LATEST.sql
index 8c5ee3e9bb..e3046cda0f 100644
--- a/backend/migrator/migration/dev/LATEST.sql
+++ b/backend/migrator/migration/dev/LATEST.sql
@@ -332,7 +332,7 @@ CREATE TABLE instance (
resource_id TEXT NOT NULL
);
-CREATE UNIQUE INDEX idx_instance_unique_resource_id ON instance(resource_id);
+CREATE UNIQUE INDEX idx_instance_unique_environment_id_resource_id ON instance(environment_id, resource_id);
ALTER SEQUENCE instance_id_seq RESTART WITH 101;
diff --git a/backend/migrator/migration/prod/1.18/0002##update_instance_unique_index.sql b/backend/migrator/migration/prod/1.18/0002##update_instance_unique_index.sql
new file mode 100644
index 0000000000..19a4155a0a
--- /dev/null
+++ b/backend/migrator/migration/prod/1.18/0002##update_instance_unique_index.sql
@@ -0,0 +1,2 @@
+DROP INDEX idx_instance_unique_resource_id;
+CREATE UNIQUE INDEX idx_instance_unique_environment_id_resource_id ON instance(environment_id, resource_id);
diff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sql
index 7fbf6b3d1c..fcdf7f650f 100644
--- a/backend/migrator/migration/prod/LATEST.sql
+++ b/backend/migrator/migration/prod/LATEST.sql
@@ -331,7 +331,7 @@ CREATE TABLE instance (
resource_id TEXT NOT NULL
);
-CREATE UNIQUE INDEX idx_instance_unique_resource_id ON instance(resource_id);
+CREATE UNIQUE INDEX idx_instance_unique_environment_id_resource_id ON instance(environment_id, resource_id);
ALTER SEQUENCE instance_id_seq RESTART WITH 101;
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index f95f5c5bb1..e01a551edb 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -241,5 +241,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("1.18.1"), releaseVersion)
+ require.Equal(t, semver.MustParse("1.18.2"), releaseVersion)
}