Skip to content

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

Re-number seed object ID

天舟887bbb08ae3d
diff --git a/backend/store/seed/0020_member.sql b/backend/store/seed/0020_member.sql
index 10aed7b7be..cded29ade4 100644
--- a/backend/store/seed/0020_member.sql
+++ b/backend/store/seed/0020_member.sql
@@ -1,5 +1,6 @@
INSERT INTO
member (
+ id,
workspace_id,
creator_id,
updater_id,
@@ -7,10 +8,11 @@ INSERT INTO
principal_id
)
VALUES
- (1, 1001, 1001, 'OWNER', 1001);
+ (2001, 1, 1001, 1001, 'OWNER', 1001);
INSERT INTO
member (
+ id,
workspace_id,
creator_id,
updater_id,
@@ -18,10 +20,11 @@ INSERT INTO
principal_id
)
VALUES
- (1001, 1001, 1001, 'OWNER', 1001);
+ (2002, 1, 1001, 1001, 'DBA', 1002);
INSERT INTO
member (
+ id,
workspace_id,
creator_id,
updater_id,
@@ -29,10 +32,11 @@ INSERT INTO
principal_id
)
VALUES
- (1, 1001, 1001, 'DBA', 1002);
+ (2003, 1, 1001, 1001, 'DEVELOPER', 1003);
INSERT INTO
member (
+ id,
workspace_id,
creator_id,
updater_id,
@@ -40,10 +44,11 @@ INSERT INTO
principal_id
)
VALUES
- (1, 1001, 1001, 'DEVELOPER', 1003);
+ (2004, 1, 1001, 1001, 'DEVELOPER', 1005);
INSERT INTO
member (
+ id,
workspace_id,
creator_id,
updater_id,
@@ -51,10 +56,11 @@ INSERT INTO
principal_id
)
VALUES
- (1001, 1001, 1001, 'DBA', 1004);
+ (102001, 1001, 1001, 1001, 'OWNER', 1001);
INSERT INTO
member (
+ id,
workspace_id,
creator_id,
updater_id,
@@ -62,4 +68,4 @@ INSERT INTO
principal_id
)
VALUES
- (1, 1001, 1001, 'DEVELOPER', 1005);
\ No newline at end of file
+ (102002, 1001, 1001, 1001, 'DBA', 1004);
\ No newline at end of file
diff --git a/backend/store/seed/0030_environment.sql b/backend/store/seed/0030_environment.sql
index 23b41aa55f..8e0928933d 100644
--- a/backend/store/seed/0030_environment.sql
+++ b/backend/store/seed/0030_environment.sql
@@ -8,7 +8,7 @@ INSERT INTO
`order`
)
VALUES
- (2001, 1, 1001, 1001, 'Sandbox A', 0);
+ (3001, 1, 1001, 1001, 'Sandbox A', 0);
INSERT INTO
environment (
@@ -20,7 +20,7 @@ INSERT INTO
`order`
)
VALUES
- (2002, 1, 1001, 1001, 'Integration', 1);
+ (3002, 1, 1001, 1001, 'Integration', 1);
INSERT INTO
environment (
@@ -32,7 +32,7 @@ INSERT INTO
`order`
)
VALUES
- (2003, 1, 1001, 1001, 'Staging', 2);
+ (3003, 1, 1001, 1001, 'Staging', 2);
INSERT INTO
environment (
@@ -44,7 +44,7 @@ INSERT INTO
`order`
)
VALUES
- (2004, 1, 1001, 1001, 'Prod', 3);
+ (3004, 1, 1001, 1001, 'Prod', 3);
INSERT INTO
environment (
@@ -58,7 +58,7 @@ INSERT INTO
)
VALUES
(
- 2005,
+ 3005,
'ARCHIVED',
1,
1001,
diff --git a/backend/store/seed/0040_instance.sql b/backend/store/seed/0040_instance.sql
index ca641ba77d..2d2a7edac4 100644
--- a/backend/store/seed/0040_instance.sql
+++ b/backend/store/seed/0040_instance.sql
@@ -12,11 +12,11 @@ INSERT INTO
)
VALUES
(
- 3001,
+ 4001,
1001,
1001,
1,
- 2001,
+ 3001,
'ON - premise MySQL instance',
'google.com',
'localhost',
@@ -37,11 +37,11 @@ INSERT INTO
)
VALUES
(
- 3002,
+ 4002,
1001,
1001,
1,
- 2002,
+ 3002,
'AWS RDS instance',
'google.com',
'127.0.0.1',
@@ -62,11 +62,11 @@ INSERT INTO
)
VALUES
(
- 3003,
+ 4003,
1001,
1001,
1,
- 2003,
+ 3003,
'GCP Cloud SQL instance',
'google.com',
'13.24.32.122',
@@ -87,11 +87,11 @@ INSERT INTO
)
VALUES
(
- 3004,
+ 4004,
1001,
1001,
1,
- 2004,
+ 3004,
'Azure SQL instance',
'google.com',
'mydb.com',
@@ -112,11 +112,11 @@ INSERT INTO
)
VALUES
(
- 3005,
+ 4005,
1001,
1001,
1,
- 2004,
+ 3004,
'AliCloud RDS instance',
'google.com',
'rds.com',
diff --git a/backend/store/seed/0050_project.sql b/backend/store/seed/0050_project.sql
index 796dc700bd..8809115f3f 100644
--- a/backend/store/seed/0050_project.sql
+++ b/backend/store/seed/0050_project.sql
@@ -9,7 +9,7 @@ INSERT INTO
)
VALUES
(
- 4001,
+ 5001,
1001,
1001,
1,
@@ -28,7 +28,7 @@ INSERT INTO
)
VALUES
(
- 4002,
+ 5002,
1001,
1001,
1,
@@ -47,7 +47,7 @@ INSERT INTO
)
VALUES
(
- 4003,
+ 5003,
1001,
1001,
1,
@@ -66,7 +66,7 @@ INSERT INTO
)
VALUES
(
- 4004,
+ 5004,
1001,
1001,
1,
@@ -86,7 +86,7 @@ INSERT INTO
)
VALUES
(
- 4005,
+ 5005,
'ARCHIVED',
1001,
1001,
@@ -106,7 +106,7 @@ INSERT INTO
)
VALUES
(
- 4006,
+ 5006,
1001,
1001,
1001,
diff --git a/backend/store/seed/README.md b/backend/store/seed/README.md
new file mode 100644
index 0000000000..735a0f51c3
--- /dev/null
+++ b/backend/store/seed/README.md
@@ -0,0 +1,6 @@
+This folder contains the seed data used for testing
+
+Each file represents the testing data for a particular table. The file name is something like 00XX where XX also corresponds to the id prefix for the record. This has couple benefits:
+
+- We can identify the resource type by just looking the id.
+- Catch errors that our code accidentally passes an ID for a different resource type.
diff --git a/frontend/src/miragejs/fixtures/memberList.json b/frontend/src/miragejs/fixtures/memberList.json
index aa337d9f48..0e9910dd62 100644
--- a/frontend/src/miragejs/fixtures/memberList.json
+++ b/frontend/src/miragejs/fixtures/memberList.json
@@ -11,16 +11,6 @@
},
{
"id": "2",
- "workspaceId": "101",
- "updaterId": "1001",
- "updatedTs": 1614657600000,
- "creatorId": "1001",
- "createdTs": 1614614400000,
- "role": "DEVELOPER",
- "principalId": "1001"
- },
- {
- "id": "3",
"workspaceId": "1",
"updaterId": "1001",
"updatedTs": 1614744000000,
@@ -30,7 +20,7 @@
"principalId": "1002"
},
{
- "id": "4",
+ "id": "3",
"workspaceId": "1",
"updaterId": "1001",
"updatedTs": 1609473600000,
@@ -39,6 +29,16 @@
"role": "DEVELOPER",
"principalId": "1003"
},
+ {
+ "id": "4",
+ "workspaceId": "1",
+ "updaterId": "1001",
+ "updatedTs": 1609646400000,
+ "creatorId": "1001",
+ "createdTs": 1609603200000,
+ "role": "DEVELOPER",
+ "principalId": "1005"
+ },
{
"id": "5",
"workspaceId": "101",
@@ -51,12 +51,12 @@
},
{
"id": "6",
- "workspaceId": "1",
+ "workspaceId": "101",
"updaterId": "1001",
- "updatedTs": 1609646400000,
+ "updatedTs": 1614657600000,
"creatorId": "1001",
- "createdTs": 1609603200000,
+ "createdTs": 1614614400000,
"role": "DEVELOPER",
- "principalId": "1005"
+ "principalId": "1001"
}
]
diff --git a/frontend/src/miragejs/seeds/index.ts b/frontend/src/miragejs/seeds/index.ts
index c3a02d8be0..c73203ee22 100644
--- a/frontend/src/miragejs/seeds/index.ts
+++ b/frontend/src/miragejs/seeds/index.ts
@@ -13,6 +13,14 @@ import {
} from "../../types";
import { databaseSlug, issueSlug } from "../../utils";
+const MEMBER_ID_START = 2001;
+const ENVIRONMENT_ID_START = 3001;
+const INSTANCE_ID_START = 4001;
+const PROJECT_ID_START = 5001;
+const PROJECT_MEMBER_ID_START = 6001;
+
+const WORKSPACE_INTERVAL = 100000;
+
/*
* Mirage JS guide on Seeds: https://miragejs.com/docs/data-layer/factories#in-development
*/
@@ -41,7 +49,7 @@ const workspacesSeeder = (server: any) => {
for (let i = 0; i < 5; i++) {
environmentList1.push(
server.create("environment", {
- id: 2001 + i,
+ id: ENVIRONMENT_ID_START + i,
workspace: workspace1,
creatorId: ws1Owner.id,
updaterId: ws1Owner.id,
@@ -54,7 +62,7 @@ const workspacesSeeder = (server: any) => {
for (let i = 0; i < 5; i++) {
environmentList2.push(
server.create("environment", {
- id: 102001 + i,
+ id: WORKSPACE_INTERVAL + ENVIRONMENT_ID_START + i,
workspace: workspace2,
creatorId: ws2DBA.id,
updaterId: ws2DBA.id,
@@ -68,7 +76,7 @@ const workspacesSeeder = (server: any) => {
for (let i = 0; i < 5; i++) {
projectList1.push(
server.create("project", {
- id: 4001 + i,
+ id: PROJECT_ID_START + i,
workspace: workspace1,
rowStatus: i < 4 ? "NORMAL" : "ARCHIVED",
creatorId: ws1Dev1.id,
@@ -77,6 +85,7 @@ const workspacesSeeder = (server: any) => {
);
server.create("projectMember", {
+ id: PROJECT_MEMBER_ID_START + i * 2 + 1,
workspace: workspace1,
project: projectList1[i],
creatorId: ws1DBA.id,
@@ -87,6 +96,7 @@ const workspacesSeeder = (server: any) => {
const userId = i % 2 == 0 ? ws1Owner.id : ws1Dev1.id;
server.create("projectMember", {
+ id: PROJECT_MEMBER_ID_START + i * 2 + 2,
workspace: workspace1,
project: projectList1[i],
creatorId: ws1Owner.id,
@@ -101,6 +111,7 @@ const workspacesSeeder = (server: any) => {
for (let i = 0; i < 1; i++) {
projectList2.push(
server.create("project", {
+ id: WORKSPACE_INTERVAL + PROJECT_ID_START + i,
workspace: workspace2,
creatorId: ws2Dev.id,
updaterId: ws2Dev.id,
@@ -108,6 +119,7 @@ const workspacesSeeder = (server: any) => {
);
server.create("projectMember", {
+ id: WORKSPACE_INTERVAL + PROJECT_MEMBER_ID_START + i,
workspace: workspace2,
project: projectList2[i],
creatorId: ws2DBA.id,
@@ -126,7 +138,7 @@ const workspacesSeeder = (server: any) => {
projectList1,
ws1DBA,
DEFAULT_PROJECT_ID,
- 2001
+ INSTANCE_ID_START
);
const instanceList2 = createInstanceList(
@@ -136,7 +148,7 @@ const workspacesSeeder = (server: any) => {
projectList2,
ws2DBA,
"2",
- 102001
+ WORKSPACE_INTERVAL + INSTANCE_ID_START
);
// Database