Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Refractor CRUD implementation to make code look more consistent
天舟f143afa301bb
diff --git a/backend/api/common.go b/backend/api/common.goindex b42a8b4895..5688f02c9a 100644--- a/backend/api/common.go+++ b/backend/api/common.go@@ -21,5 +21,5 @@ func (e RowStatus) String() string {}type ResourceObject struct {- ID int `jsonapi:"primary,resource-object"`+ ID int `jsonapi:"primary,resourceObject"`}diff --git a/backend/api/dataSource.go b/backend/api/dataSource.goindex d1e3524c7b..588cf476a8 100644--- a/backend/api/dataSource.go+++ b/backend/api/dataSource.go@@ -23,18 +23,18 @@ func (e DataSourceType) String() string {}type DataSource struct {- ID int `jsonapi:"primary,data-source"`-- // Related fields- Instance *ResourceObject `jsonapi:"relation,instance"`- Database *ResourceObject `jsonapi:"relation,database"`+ ID int `jsonapi:"primary,dataSource"`// Standard fields- WorkspaceId intCreatorId int `jsonapi:"attr,creatorId"`CreatedTs int64 `jsonapi:"attr,createdTs"`UpdaterId int `jsonapi:"attr,updaterId"`UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ WorkspaceId int++ // Related fields+ Instance *ResourceObject `jsonapi:"relation,instance"`+ Database *ResourceObject `jsonapi:"relation,database"`// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -44,15 +44,15 @@ type DataSource struct {}type DataSourceCreate struct {+ // Standard fields+ // Value is assigned from the jwt subject field passed by the client.+ CreatorId int+ WorkspaceId int+// Related fieldsInstanceId intDatabaseId int- // Standard fields- WorkspaceId int- // Value is assigned from the jwt subject field passed by the client.- CreatorId int-// Domain specific fieldsName string `jsonapi:"attr,name"`Type DataSourceType `jsonapi:"attr,type"`@@ -63,17 +63,22 @@ type DataSourceCreate struct {type DataSourceFind struct {// Standard fieldsWorkspaceId *int- InstanceId *int- DatabaseId *int- Type *DataSourceType++ // Related fields+ InstanceId *int+ DatabaseId *int++ // Domain specific fields+ Type *DataSourceType}type DataSourcePatch struct {+ ID int `jsonapi:"primary,dataSourcePatch"`+// Standard fields- ID int `jsonapi:"primary,data-source-patch"`- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int// Domain specific fieldsUsername *string `jsonapi:"attr,username"`diff --git a/backend/api/database.go b/backend/api/database.goindex 865e201caa..0919c1ec41 100644--- a/backend/api/database.go+++ b/backend/api/database.go@@ -27,6 +27,13 @@ func (e SyncStatus) String() string {type Database struct {ID int `jsonapi:"primary,database"`+ // Standard fields+ CreatorId int `jsonapi:"attr,creatorId"`+ CreatedTs int64 `jsonapi:"attr,createdTs"`+ UpdaterId int `jsonapi:"attr,updaterId"`+ UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ WorkspaceId int+// Related fieldsProject *Project `jsonapi:"relation,project"`ProjectId int@@ -34,13 +41,6 @@ type Database struct {InstanceId intDataSourceList []*DataSource `jsonapi:"relation,dataSource"`- // Standard fields- WorkspaceId int- CreatorId int `jsonapi:"attr,creatorId"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterId int `jsonapi:"attr,updaterId"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`-// Domain specific fieldsName string `jsonapi:"attr,name"`SyncStatus SyncStatus `jsonapi:"attr,syncStatus"`@@ -49,37 +49,43 @@ type Database struct {}type DatabaseCreate struct {+ // Standard fields+ // Value is assigned from the jwt subject field passed by the client.+ CreatorId int+ WorkspaceId int+// Related fieldsProjectId intInstanceId int- // Standard fields- WorkspaceId int- // Value is assigned from the jwt subject field passed by the client.- CreatorId int-// Domain specific fieldsName string `jsonapi:"attr,name"`IssueId string `jsonapi:"attr,issueId"`}type DatabaseFind struct {+ ID *int+// Standard fields- ID *int- WorkspaceId *int- InstanceId *int+ WorkspaceId *int++ // Related fields+ InstanceId *int++ // Domain specific fieldsIncludeAllDatabase bool}type DatabasePatch struct {- // Related fields- ProjectId *int `jsonapi:"attr,project"`+ ID int `jsonapi:"primary,database-patch"`// Standard fields- ID int `jsonapi:"primary,database-patch"`- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int++ // Related fields+ ProjectId *int `jsonapi:"attr,project"`}type DatabaseService interface {diff --git a/backend/api/environment.go b/backend/api/environment.goindex eb37e47e39..8f707622ff 100644--- a/backend/api/environment.go+++ b/backend/api/environment.go@@ -7,11 +7,11 @@ type Environment struct {// Standard fieldsRowStatus RowStatus `jsonapi:"attr,rowStatus"`+ CreatorId int `jsonapi:"attr,creatorId"`+ CreatedTs int64 `jsonapi:"attr,createdTs"`+ UpdaterId int `jsonapi:"attr,updaterId"`+ UpdatedTs int64 `jsonapi:"attr,updatedTs"`WorkspaceId int- CreatorId int `jsonapi:"attr,creatorId"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterId int `jsonapi:"attr,updaterId"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -20,27 +20,29 @@ type Environment struct {type EnvironmentCreate struct {// Standard fields- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- CreatorId int+ CreatorId int+ WorkspaceId int// Domain specific fieldsName string `jsonapi:"attr,name"`}type EnvironmentFind struct {+ ID *int+// Standard fields- ID *intWorkspaceId *int}type EnvironmentPatch struct {+ ID int `jsonapi:"primary,environmentPatch"`+// Standard fields- ID int `jsonapi:"primary,environment-patch"`- RowStatus *string `jsonapi:"attr,rowStatus"`- WorkspaceId int+ RowStatus *string `jsonapi:"attr,rowStatus"`// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int// Domain specific fieldsName *string `jsonapi:"attr,name"`@@ -48,8 +50,9 @@ type EnvironmentPatch struct {}type EnvironmentDelete struct {- // Standard fieldsID int++ // Standard fields// Value is assigned from the jwt subject field passed by the client.DeleterId int}diff --git a/backend/api/instance.go b/backend/api/instance.goindex 34b1b06604..9a1c75d102 100644--- a/backend/api/instance.go+++ b/backend/api/instance.go@@ -5,36 +5,34 @@ import "context"type Instance struct {ID int `jsonapi:"primary,instance"`+ // Standard fields+ RowStatus RowStatus `jsonapi:"attr,rowStatus"`+ CreatorId int `jsonapi:"attr,creatorId"`+ CreatedTs int64 `jsonapi:"attr,createdTs"`+ UpdaterId int `jsonapi:"attr,updaterId"`+ UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ WorkspaceId int+// Related fieldsEnvironmentId intEnvironment *Environment `jsonapi:"relation,environment"`DataSourceList []*DataSource `jsonapi:"relation,dataSource"`- // Standard fields- RowStatus RowStatus `jsonapi:"attr,rowStatus"`- WorkspaceId int- CreatorId int `jsonapi:"attr,creatorId"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterId int `jsonapi:"attr,updaterId"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`-// Domain specific fieldsName string `jsonapi:"attr,name"`ExternalLink string `jsonapi:"attr,externalLink"`Host string `jsonapi:"attr,host"`Port string `jsonapi:"attr,port"`- // Username string `jsonapi:"attr,username"`- // Password string `jsonapi:"attr,password"`}type InstanceCreate struct {- // Related fields- EnvironmentId string `jsonapi:"attr,environmentId"`-// Standard fields- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- CreatorId int+ CreatorId int+ WorkspaceId int++ // Related fields+ EnvironmentId string `jsonapi:"attr,environmentId"`// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -46,18 +44,20 @@ type InstanceCreate struct {}type InstanceFind struct {+ ID *int+// Standard fields- ID *intWorkspaceId *int}type InstancePatch struct {+ ID int `jsonapi:"primary,instancePatch"`+// Standard fields- ID int `jsonapi:"primary,instancePatch"`- RowStatus *string `jsonapi:"attr,rowStatus"`- WorkspaceId int+ RowStatus *string `jsonapi:"attr,rowStatus"`// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int// Domain specific fieldsName *string `jsonapi:"attr,name"`diff --git a/backend/api/member.go b/backend/api/member.goindex 78910baa2a..64421fc528 100644--- a/backend/api/member.go+++ b/backend/api/member.go@@ -26,11 +26,11 @@ type Member struct {ID int `jsonapi:"primary,principal"`// Standard fields- WorkspaceId intCreatorId int `jsonapi:"attr,creatorId"`CreatedTs int64 `jsonapi:"attr,createdTs"`UpdaterId int `jsonapi:"attr,updaterId"`UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ WorkspaceId int// Domain specific fieldsRole Role `jsonapi:"attr,role"`@@ -39,9 +39,9 @@ type Member struct {type MemberCreate struct {// Standard fields- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- CreatorId int+ CreatorId int+ WorkspaceId int// Domain specific fieldsRole Role `jsonapi:"attr,role"`@@ -49,8 +49,9 @@ type MemberCreate struct {}type MemberFind struct {+ ID *int+// Standard fields- ID *intWorkspaceId *int// Domain specific fields@@ -58,19 +59,21 @@ type MemberFind struct {}type MemberPatch struct {+ ID int+// Standard fields- ID int- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int// Domain specific fieldsRole *string `jsonapi:"attr,role"`}type MemberDelete struct {- // Standard fieldsID int++ // Standard fields// Value is assigned from the jwt subject field passed by the client.DeleterId int}diff --git a/backend/api/principal.go b/backend/api/principal.goindex e774769c4b..ef71ad7744 100644--- a/backend/api/principal.go+++ b/backend/api/principal.go@@ -55,7 +55,7 @@ type Principal struct {Type PrincipalType `jsonapi:"attr,type"`Name string `jsonapi:"attr,name"`Email string `jsonapi:"attr,email"`- // Not needed to return to the client+ // No need to return to the clientPasswordHash string}@@ -74,7 +74,6 @@ type PrincipalCreate struct {}type PrincipalFind struct {- // Standard fieldsID *int// Domain specific fields@@ -82,8 +81,9 @@ type PrincipalFind struct {}type PrincipalPatch struct {- // Standard fieldsID int++ // Standard fields// Value is assigned from the jwt subject field passed by the client.UpdaterId intdiff --git a/backend/api/project.go b/backend/api/project.goindex e5db91a3dc..69efe460d2 100644--- a/backend/api/project.go+++ b/backend/api/project.go@@ -5,16 +5,16 @@ import "context"type Project struct {ID int `jsonapi:"primary,project"`- // Related fields- ProjectMemberList []*ProjectMember `jsonapi:"relation,project-member-list"`-// Standard fieldsRowStatus RowStatus `jsonapi:"attr,rowStatus"`+ CreatorId int `jsonapi:"attr,creatorId"`+ CreatedTs int64 `jsonapi:"attr,createdTs"`+ UpdaterId int `jsonapi:"attr,updaterId"`+ UpdatedTs int64 `jsonapi:"attr,updatedTs"`WorkspaceId int- CreatorId int `jsonapi:"attr,creatorId"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterId int `jsonapi:"attr,updaterId"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`++ // Related fields+ ProjectMemberList []*ProjectMember `jsonapi:"relation,projectMember"`// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -23,9 +23,9 @@ type Project struct {type ProjectCreate struct {// Standard fields- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- CreatorId int+ CreatorId int+ WorkspaceId int// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -33,18 +33,20 @@ type ProjectCreate struct {}type ProjectFind struct {+ ID *int+// Standard fields- ID *intWorkspaceId *int}type ProjectPatch struct {+ ID int `jsonapi:"primary,projectPatch"`+// Standard fields- ID int `jsonapi:"primary,project-patch"`- RowStatus *string `jsonapi:"attr,rowStatus"`- WorkspaceId int+ RowStatus *string `jsonapi:"attr,rowStatus"`// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int// Domain specific fieldsName *string `jsonapi:"attr,name"`diff --git a/backend/api/projectMember.go b/backend/api/projectMember.goindex eda74ecbaa..be812db768 100644--- a/backend/api/projectMember.go+++ b/backend/api/projectMember.go@@ -20,17 +20,17 @@ func (e ProjectRole) String() string {}type ProjectMember struct {- ID string `jsonapi:"primary,project-member"`-- // Related fields- Project *ResourceObject `jsonapi:"relation,project"`+ ID int `jsonapi:"primary,projectMember"`// Standard fields- WorkspaceId intCreatorId int `jsonapi:"attr,creatorId"`CreatedTs int64 `jsonapi:"attr,createdTs"`UpdaterId int `jsonapi:"attr,updaterId"`UpdatedTs int64 `jsonapi:"attr,updatedTs"`+ WorkspaceId int++ // Related fields+ Project *ResourceObject `jsonapi:"relation,project"`// Domain specific fieldsRole string `jsonapi:"attr,role"`@@ -38,13 +38,13 @@ type ProjectMember struct {}type ProjectMemberCreate struct {- // Related fields- ProjectId int-// Standard fields- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- CreatorId int+ CreatorId int+ WorkspaceId int++ // Related fields+ ProjectId int// Domain specific fieldsRole ProjectRole `jsonapi:"attr,role"`@@ -52,28 +52,31 @@ type ProjectMemberCreate struct {}type ProjectMemberFind struct {- // Related fields- ProjectId *int `jsonapi:"attr,projectId"`+ ID *int// Standard fields- ID *intWorkspaceId *int++ // Related fields+ ProjectId *int}type ProjectMemberPatch struct {+ ID int+// Standard fields- ID int- WorkspaceId int// Value is assigned from the jwt subject field passed by the client.- UpdaterId int+ UpdaterId int+ WorkspaceId int// Domain specific fieldsRole *string `jsonapi:"attr,role"`}type ProjectMemberDelete struct {- // Standard fieldsID int++ // Standard fields// Value is assigned from the jwt subject field passed by the client.DeleterId int}diff --git a/backend/store/dataSource.go b/backend/store/dataSource.goindex 61fbf7881e..35674e0923 100644--- a/backend/store/dataSource.go+++ b/backend/store/dataSource.go@@ -107,9 +107,9 @@ func (s *DataSourceService) createDataSource(ctx context.Context, tx *Tx, create// Insert row into dataSource.row, err := tx.QueryContext(ctx, `INSERT INTO data_source (- workspace_id,creator_id,updater_id,+ workspace_id,instance_id,database_id,name,@@ -118,11 +118,11 @@ func (s *DataSourceService) createDataSource(ctx context.Context, tx *Tx, createpassword)VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, instance_id, database_id, name, type, username, password+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, instance_id, database_id, name, type, username, password`,- create.WorkspaceId,create.CreatorId,create.CreatorId,+ create.WorkspaceId,create.InstanceId,create.DatabaseId,create.Name,@@ -142,11 +142,11 @@ func (s *DataSourceService) createDataSource(ctx context.Context, tx *Tx, createdataSource.Database = &api.ResourceObject{}if err := row.Scan(&dataSource.ID,- &dataSource.WorkspaceId,&dataSource.CreatorId,&dataSource.CreatedTs,&dataSource.UpdaterId,&dataSource.UpdatedTs,+ &dataSource.WorkspaceId,&dataSource.Instance.ID,&dataSource.Database.ID,&dataSource.Name,@@ -179,11 +179,11 @@ func (s *DataSourceService) findDataSourceList(ctx context.Context, tx *Tx, findrows, err := tx.QueryContext(ctx, `SELECTid,- workspace_id,creator_id,created_ts,updater_id,updated_ts,+ workspace_id,instance_id,database_id,name,@@ -207,11 +207,11 @@ func (s *DataSourceService) findDataSourceList(ctx context.Context, tx *Tx, finddataSource.Database = &api.ResourceObject{}if err := rows.Scan(&dataSource.ID,- &dataSource.WorkspaceId,&dataSource.CreatorId,&dataSource.CreatedTs,&dataSource.UpdaterId,&dataSource.UpdatedTs,+ &dataSource.WorkspaceId,&dataSource.Instance.ID,&dataSource.Database.ID,&dataSource.Name,@@ -249,7 +249,7 @@ func (s *DataSourceService) patchDataSource(ctx context.Context, tx *Tx, patch *UPDATE data_sourceSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, instance_id, database_id, name, type, username, password+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, instance_id, database_id, name, type, username, password`,args...,)@@ -264,11 +264,11 @@ func (s *DataSourceService) patchDataSource(ctx context.Context, tx *Tx, patch *dataSource.Database = &api.ResourceObject{}if err := row.Scan(&dataSource.ID,- &dataSource.WorkspaceId,&dataSource.CreatorId,&dataSource.CreatedTs,&dataSource.UpdaterId,&dataSource.UpdatedTs,+ &dataSource.WorkspaceId,&dataSource.Instance.ID,&dataSource.Database.ID,&dataSource.Name,diff --git a/backend/store/database.go b/backend/store/database.goindex 3926893fe9..371e18cb15 100644--- a/backend/store/database.go+++ b/backend/store/database.go@@ -107,9 +107,9 @@ func (s *DatabaseService) createDatabase(ctx context.Context, tx *Tx, create *ap// Insert row into database.row, err := tx.QueryContext(ctx, `INSERT INTO db (- workspace_id,creator_id,updater_id,+ workspace_id,instance_id,project_id,name,@@ -118,7 +118,7 @@ func (s *DatabaseService) createDatabase(ctx context.Context, tx *Tx, create *apfingerprint)VALUES (?, ?, ?, ?, ?, ?, 'NOT_FOUND', 0, '')- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, instance_id, project_id, name, sync_status, last_successful_sync, fingerprint+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, instance_id, project_id, name, sync_status, last_successful_sync, fingerprint`,create.WorkspaceId,create.CreatorId,@@ -137,11 +137,11 @@ func (s *DatabaseService) createDatabase(ctx context.Context, tx *Tx, create *apvar database api.Databaseif err := row.Scan(&database.ID,- &database.WorkspaceId,&database.CreatorId,&database.CreatedTs,&database.UpdaterId,&database.UpdatedTs,+ &database.WorkspaceId,&database.InstanceId,&database.ProjectId,&database.Name,@@ -173,11 +173,11 @@ func (s *DatabaseService) findDatabaseList(ctx context.Context, tx *Tx, find *aprows, err := tx.QueryContext(ctx, `SELECTid,- workspace_id,creator_id,created_ts,updater_id,updated_ts,+ workspace_id,instance_id,project_id,name,@@ -199,11 +199,11 @@ func (s *DatabaseService) findDatabaseList(ctx context.Context, tx *Tx, find *apvar database api.Databaseif err := rows.Scan(&database.ID,- &database.WorkspaceId,&database.CreatorId,&database.CreatedTs,&database.UpdaterId,&database.UpdatedTs,+ &database.WorkspaceId,&database.InstanceId,&database.ProjectId,&database.Name,@@ -238,7 +238,7 @@ func (s *DatabaseService) patchDatabase(ctx context.Context, tx *Tx, patch *api.UPDATE dbSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, instance_id, project_id, name, sync_status, last_successful_sync, fingerprint+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, instance_id, project_id, name, sync_status, last_successful_sync, fingerprint`,args...,)@@ -251,11 +251,11 @@ func (s *DatabaseService) patchDatabase(ctx context.Context, tx *Tx, patch *api.var database api.Databaseif err := row.Scan(&database.ID,- &database.WorkspaceId,&database.CreatorId,&database.CreatedTs,&database.UpdaterId,&database.UpdatedTs,+ &database.WorkspaceId,&database.InstanceId,&database.ProjectId,&database.Name,diff --git a/backend/store/environment.go b/backend/store/environment.goindex 15f7241f9f..bfbabad9bc 100644--- a/backend/store/environment.go+++ b/backend/store/environment.go@@ -151,18 +151,18 @@ func (s *EnvironmentService) createEnvironment(ctx context.Context, tx *Tx, crea// Insert row into database.row2, err2 := tx.QueryContext(ctx, `INSERT INTO environment (- workspace_id,creator_id,updater_id,+ workspace_id,name,`+"`order`"+`)VALUES (?, ?, ?, ?, ?)- RETURNING id, row_status, workspace_id, creator_id, created_ts, updater_id, updated_ts, name, `+"`order`"+`+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, workspace_id, name, `+"`order`"+``,- create.WorkspaceId,create.CreatorId,create.CreatorId,+ create.WorkspaceId,create.Name,order+1,)@@ -177,11 +177,11 @@ func (s *EnvironmentService) createEnvironment(ctx context.Context, tx *Tx, creaif err := row2.Scan(&environment.ID,&environment.RowStatus,- &environment.WorkspaceId,&environment.CreatorId,&environment.CreatedTs,&environment.UpdaterId,&environment.UpdatedTs,+ &environment.WorkspaceId,&environment.Name,&environment.Order,); err != nil {@@ -205,11 +205,11 @@ func (s *EnvironmentService) findEnvironmentList(ctx context.Context, tx *Tx, fiSELECTid,row_status,- workspace_id,creator_id,created_ts,updater_id,updated_ts,+ workspace_id,name,`+"`order`"+`FROM environment@@ -228,11 +228,11 @@ func (s *EnvironmentService) findEnvironmentList(ctx context.Context, tx *Tx, fiif err := rows.Scan(&environment.ID,&environment.RowStatus,- &environment.WorkspaceId,&environment.CreatorId,&environment.CreatedTs,&environment.UpdaterId,&environment.UpdatedTs,+ &environment.WorkspaceId,&environment.Name,&environment.Order,); err != nil {@@ -269,7 +269,7 @@ func (s *EnvironmentService) patchEnvironment(ctx context.Context, tx *Tx, patchUPDATE environmentSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, row_status, workspace_id, creator_id, created_ts, updater_id, updated_ts, name, `+"`order`"+`+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, workspace_id, name, `+"`order`"+``,args...,)@@ -283,11 +283,11 @@ func (s *EnvironmentService) patchEnvironment(ctx context.Context, tx *Tx, patchif err := row.Scan(&environment.ID,&environment.RowStatus,- &environment.WorkspaceId,&environment.CreatorId,&environment.CreatedTs,&environment.UpdaterId,&environment.UpdatedTs,+ &environment.WorkspaceId,&environment.Name,&environment.Order,); err != nil {diff --git a/backend/store/member.go b/backend/store/member.goindex f8ef98b1a2..05c979f554 100644--- a/backend/store/member.go+++ b/backend/store/member.go@@ -128,18 +128,18 @@ func createMember(ctx context.Context, tx *Tx, create *api.MemberCreate) (*api.M// Insert row into database.row, err := tx.QueryContext(ctx, `INSERT INTO member (- workspace_id,creator_id,updater_id,+ workspace_id,role,principal_id)VALUES (?, ?, ?, ?, ?)- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, role, principal_id+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, role, principal_id`,- create.WorkspaceId,create.CreatorId,create.CreatorId,+ create.WorkspaceId,create.Role,create.PrincipalId,)@@ -153,11 +153,11 @@ func createMember(ctx context.Context, tx *Tx, create *api.MemberCreate) (*api.Mvar member api.Memberif err := row.Scan(&member.ID,- &member.WorkspaceId,&member.CreatorId,&member.CreatedTs,&member.UpdaterId,&member.UpdatedTs,+ &member.WorkspaceId,&member.Role,&member.PrincipalId,); err != nil {@@ -183,11 +183,11 @@ func findMemberList(ctx context.Context, tx *Tx, find *api.MemberFind) (_ []*apirows, err := tx.QueryContext(ctx, `SELECTid,- workspace_id,creator_id,created_ts,updater_id,updated_ts,+ workspace_id,role,principal_idFROM member@@ -205,11 +205,11 @@ func findMemberList(ctx context.Context, tx *Tx, find *api.MemberFind) (_ []*apivar member api.Memberif err := rows.Scan(&member.ID,- &member.WorkspaceId,&member.CreatorId,&member.CreatedTs,&member.UpdaterId,&member.UpdatedTs,+ &member.WorkspaceId,&member.Role,&member.PrincipalId,); err != nil {@@ -240,7 +240,7 @@ func patchMember(ctx context.Context, tx *Tx, patch *api.MemberPatch) (*api.MembUPDATE memberSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, role, principal_id+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, role, principal_id`,args...,)@@ -253,11 +253,11 @@ func patchMember(ctx context.Context, tx *Tx, patch *api.MemberPatch) (*api.Membvar member api.Memberif err := row.Scan(&member.ID,- &member.WorkspaceId,&member.CreatorId,&member.CreatedTs,&member.UpdaterId,&member.UpdatedTs,+ &member.WorkspaceId,&member.Role,&member.PrincipalId,); err != nil {diff --git a/backend/store/migration/0001_init_schema.up.sql b/backend/store/migration/0001_init_schema.up.sqlindex 98fe1e792c..f5e01d4b3c 100644--- a/backend/store/migration/0001_init_schema.up.sql+++ b/backend/store/migration/0001_init_schema.up.sql@@ -112,11 +112,11 @@ CREATE TABLE member (row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED', 'PENDING_DELETE')) DEFAULT 'NORMAL',- workspace_id INTEGER NOT NULL REFERENCES workspace (id),creator_id INTEGER NOT NULL REFERENCES principal (id),created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),updater_id INTEGER NOT NULL REFERENCES principal (id),updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),+ workspace_id INTEGER NOT NULL REFERENCES workspace (id),`role` TEXT NOT NULL CHECK (`role` IN ('OWNER', 'DBA', 'DEVELOPER')),@@ -148,11 +148,11 @@ CREATE TABLE environment (row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED', 'PENDING_DELETE')) DEFAULT 'NORMAL',- workspace_id INTEGER NOT NULL REFERENCES workspace (id),creator_id INTEGER NOT NULL REFERENCES principal (id),created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),updater_id INTEGER NOT NULL REFERENCES principal (id),updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),+ workspace_id INTEGER NOT NULL REFERENCES workspace (id),name TEXT NOT NULL,`order` INTEGER NOT NULL,UNIQUE(workspace_id, name)diff --git a/backend/store/projectMember.go b/backend/store/projectMember.goindex c689c3ca14..a1a59436eb 100644--- a/backend/store/projectMember.go+++ b/backend/store/projectMember.go@@ -128,19 +128,19 @@ func createProjectMember(ctx context.Context, tx *Tx, create *api.ProjectMemberC// Insert row into database.row, err := tx.QueryContext(ctx, `INSERT INTO project_member (- workspace_id,creator_id,updater_id,+ workspace_id,project_id,`+"`role`,"+`principal_id)VALUES (?, ?, ?, ?, ?, ?)- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, project_id, role, principal_id+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, project_id, role, principal_id`,- create.WorkspaceId,create.CreatorId,create.CreatorId,+ create.WorkspaceId,create.ProjectId,create.Role,create.PrincipalId,@@ -156,11 +156,11 @@ func createProjectMember(ctx context.Context, tx *Tx, create *api.ProjectMemberCprojectMember.Project = &api.ResourceObject{}if err := row.Scan(&projectMember.ID,- &projectMember.WorkspaceId,&projectMember.CreatorId,&projectMember.CreatedTs,&projectMember.UpdaterId,&projectMember.UpdatedTs,+ &projectMember.WorkspaceId,&projectMember.Project.ID,&projectMember.Role,&projectMember.PrincipalId,@@ -187,11 +187,11 @@ func findProjectMemberList(ctx context.Context, tx *Tx, find *api.ProjectMemberFrows, err := tx.QueryContext(ctx, `SELECTid,- workspace_id,creator_id,created_ts,updater_id,updated_ts,+ workspace_id,project_id,role,principal_id@@ -211,11 +211,11 @@ func findProjectMemberList(ctx context.Context, tx *Tx, find *api.ProjectMemberFprojectMember.Project = &api.ResourceObject{}if err := rows.Scan(&projectMember.ID,- &projectMember.WorkspaceId,&projectMember.CreatorId,&projectMember.CreatedTs,&projectMember.UpdaterId,&projectMember.UpdatedTs,+ &projectMember.WorkspaceId,&projectMember.Project.ID,&projectMember.Role,&projectMember.PrincipalId,@@ -247,7 +247,7 @@ func patchProjectMember(ctx context.Context, tx *Tx, patch *api.ProjectMemberPatUPDATE project_memberSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, workspace_id, creator_id, created_ts, updater_id, updated_ts, project_id, role, principal_id+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, workspace_id, project_id, role, principal_id`,args...,)@@ -261,11 +261,11 @@ func patchProjectMember(ctx context.Context, tx *Tx, patch *api.ProjectMemberPatprojectMember.Project = &api.ResourceObject{}if err := row.Scan(&projectMember.ID,- &projectMember.WorkspaceId,&projectMember.CreatorId,&projectMember.CreatedTs,&projectMember.UpdaterId,&projectMember.UpdatedTs,+ &projectMember.WorkspaceId,&projectMember.Project.ID,&projectMember.Role,&projectMember.PrincipalId,diff --git a/backend/store/seed/0020_member.sql b/backend/store/seed/0020_member.sqlindex cded29ade4..766a54cd27 100644--- a/backend/store/seed/0020_member.sql+++ b/backend/store/seed/0020_member.sql@@ -13,45 +13,45 @@ VALUESINSERT INTOmember (id,- workspace_id,creator_id,updater_id,+ workspace_id,role,principal_id)VALUES- (2002, 1, 1001, 1001, 'DBA', 1002);+ (2002, 1001, 1001, 1, 'DBA', 1002);INSERT INTOmember (id,- workspace_id,creator_id,updater_id,+ workspace_id,role,principal_id)VALUES- (2003, 1, 1001, 1001, 'DEVELOPER', 1003);+ (2003, 1001, 1001, 1, 'DEVELOPER', 1003);INSERT INTOmember (id,- workspace_id,creator_id,updater_id,+ workspace_id,role,principal_id)VALUES- (2004, 1, 1001, 1001, 'DEVELOPER', 1005);+ (2004, 1001, 1001, 1, 'DEVELOPER', 1005);INSERT INTOmember (id,- workspace_id,creator_id,updater_id,+ workspace_id,role,principal_id)@@ -61,9 +61,9 @@ VALUESINSERT INTOmember (id,- workspace_id,creator_id,updater_id,+ workspace_id,role,principal_id)diff --git a/backend/store/seed/0050_environment.sql b/backend/store/seed/0050_environment.sqlindex e394011afb..15e2bc2ecb 100644--- a/backend/store/seed/0050_environment.sql+++ b/backend/store/seed/0050_environment.sql@@ -1,58 +1,86 @@INSERT INTOenvironment (id,- workspace_id,creator_id,updater_id,+ workspace_id,name,`order`)VALUES- (5001, 1, 1001, 1001, 'Sandbox A', 0);+ (+ 5001,+ 1001,+ 1001,+ 1,+ 'Sandbox A',+ 0+ );INSERT INTOenvironment (id,- workspace_id,creator_id,updater_id,+ workspace_id,name,`order`)VALUES- (5002, 1, 1001, 1001, 'Integration', 1);+ (+ 5002,+ 1001,+ 1001,+ 1,+ 'Integration',+ 1+ );INSERT INTOenvironment (id,- workspace_id,creator_id,updater_id,+ workspace_id,name,`order`)VALUES- (5003, 1, 1001, 1001, 'Staging', 2);+ (+ 5003,+ 1001,+ 1001,+ 1,+ 'Staging',+ 2+ );INSERT INTOenvironment (id,- workspace_id,creator_id,updater_id,+ workspace_id,name,`order`)VALUES- (5004, 1, 1001, 1001, 'Prod', 3);+ (+ 5004,+ 1001,+ 1001,+ 1,+ 'Prod',+ 3+ );INSERT INTOenvironment (id,row_status,- workspace_id,creator_id,updater_id,+ workspace_id,name,`order`)@@ -60,9 +88,9 @@ VALUES(3005,'ARCHIVED',- 1,1001,1001,+ 1,'Archived Env 1',4);\ No newline at end of filediff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.tsindex 827ecc3a9b..725f98c9f5 100644--- a/frontend/src/store/modules/instance.ts+++ b/frontend/src/store/modules/instance.ts@@ -41,7 +41,7 @@ function convert(for (const item of includedList || []) {if (- item.type == "data-source" &&+ item.type == "dataSource" &&item.attributes.type == "ADMIN" &&(item.relationships!.instance.data as ResourceIdentifier).id ==instance.iddiff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.tsindex 3242b879ae..b5f196a571 100644--- a/frontend/src/store/modules/project.ts+++ b/frontend/src/store/modules/project.ts@@ -51,7 +51,7 @@ function convert(const memberList: ProjectMember[] = [];for (const item of includedList || []) {if (- item.type == "project-member" &&+ item.type == "projectMember" &&(item.relationships!.project.data as ResourceIdentifier).id == project.id) {const member = convertMember(item, rootGetters);