Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: no trigger and function (#11562)
Danny Xu5baebbca4065
diff --git a/backend/migrator/migration/prod/2.15/0020##no_trigger.sql b/backend/migrator/migration/prod/2.15/0020##no_trigger.sqlnew file mode 100644index 0000000000..668476f068--- /dev/null+++ b/backend/migrator/migration/prod/2.15/0020##no_trigger.sql@@ -0,0 +1,40 @@+DROP TRIGGER update_idp_updated_ts ON idp;+DROP TRIGGER update_principal_updated_ts ON principal;+DROP TRIGGER update_setting_updated_ts ON setting;+DROP TRIGGER update_role_updated_ts ON role;+DROP TRIGGER update_member_updated_ts ON member;+DROP TRIGGER update_environment_updated_ts ON environment;+DROP TRIGGER update_policy_updated_ts ON policy;+DROP TRIGGER update_project_updated_ts ON project;+DROP TRIGGER update_project_member_updated_ts ON project_member;+DROP TRIGGER update_project_webhook_updated_ts ON project_webhook;+DROP TRIGGER update_instance_updated_ts ON instance;+DROP TRIGGER update_instance_user_updated_ts ON instance_user;+DROP TRIGGER update_db_updated_ts ON db;+DROP TRIGGER update_db_schema_updated_ts ON db_schema;+DROP TRIGGER update_data_source_updated_ts ON data_source;+DROP TRIGGER update_pipeline_updated_ts ON pipeline;+DROP TRIGGER update_stage_updated_ts ON stage;+DROP TRIGGER update_task_updated_ts ON task;+DROP TRIGGER update_task_dag_updated_ts ON task_dag;+DROP TRIGGER update_task_run_updated_ts ON task_run;+DROP TRIGGER update_plan_updated_ts ON plan;+DROP TRIGGER update_plan_check_run_updated_ts ON plan_check_run;+DROP TRIGGER update_instance_change_history_updated_ts ON instance_change_history;+DROP TRIGGER update_activity_updated_ts ON activity;+DROP TRIGGER update_issue_comment_updated_ts ON issue_comment;+DROP TRIGGER update_vcs_updated_ts ON vcs;+DROP TRIGGER update_vcs_connector_updated_ts ON vcs_connector;+DROP TRIGGER update_anomaly_updated_ts ON anomaly;+DROP TRIGGER update_deployment_config_updated_ts ON deployment_config;+DROP TRIGGER update_sheet_updated_ts ON sheet;+DROP TRIGGER update_worksheet_updated_ts ON worksheet;+DROP TRIGGER update_external_approval_updated_ts ON external_approval;+DROP TRIGGER update_risk_updated_ts ON risk;+DROP TRIGGER update_slow_query_updated_ts ON slow_query;+DROP TRIGGER update_db_group_updated_ts ON db_group;+DROP TRIGGER update_schema_group_updated_ts ON schema_group;+DROP TRIGGER update_changelist_updated_ts ON changelist;+DROP TRIGGER update_branch_updated_ts ON branch;+DROP TRIGGER update_issue_updated_ts ON issue;+DROP FUNCTION trigger_update_updated_ts;\ No newline at end of filediff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sqlindex f77afa9351..b15983cdef 100644--- a/backend/migrator/migration/prod/LATEST.sql+++ b/backend/migrator/migration/prod/LATEST.sql@@ -1,15 +1,6 @@-- TypeCREATE TYPE row_status AS ENUM ('NORMAL', 'ARCHIVED');--- updated_ts trigger.-CREATE OR REPLACE FUNCTION trigger_update_updated_ts()-RETURNS TRIGGER AS $$-BEGIN- NEW.updated_ts = extract(epoch from now());- RETURN NEW;-END;-$$ LANGUAGE plpgsql;--- idp stores generic identity provider.CREATE TABLE idp (id SERIAL PRIMARY KEY,@@ -28,12 +19,6 @@ CREATE UNIQUE INDEX idx_idp_unique_resource_id ON idp(resource_id);ALTER SEQUENCE idp_id_seq RESTART WITH 101;-CREATE TRIGGER update_idp_updated_ts-BEFORE-UPDATE- ON idp FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- principalCREATE TABLE principal (id SERIAL PRIMARY KEY,@@ -50,12 +35,6 @@ CREATE TABLE principal (mfa_config JSONB NOT NULL DEFAULT '{}');-CREATE TRIGGER update_principal_updated_ts-BEFORE-UPDATE- ON principal FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Default bytebase system account id is 1INSERT INTOprincipal (@@ -119,12 +98,6 @@ CREATE UNIQUE INDEX idx_setting_unique_name ON setting(name);ALTER SEQUENCE setting_id_seq RESTART WITH 101;-CREATE TRIGGER update_setting_updated_ts-BEFORE-UPDATE- ON setting FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- RoleCREATE TABLE role (id BIGSERIAL PRIMARY KEY,@@ -144,12 +117,6 @@ CREATE UNIQUE INDEX idx_role_unique_resource_id on role (resource_id);ALTER SEQUENCE role_id_seq RESTART WITH 101;-CREATE TRIGGER update_role_updated_ts-BEFORE-UPDATE- ON role FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Member-- We separate the concept from Principal because if we support multiple workspace in the future, each workspace can have different member for the same principalCREATE TABLE member (@@ -167,12 +134,6 @@ CREATE INDEX idx_member_principal_id ON member (principal_id);ALTER SEQUENCE member_id_seq RESTART WITH 101;-CREATE TRIGGER update_member_updated_ts-BEFORE-UPDATE- ON member FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- EnvironmentCREATE TABLE environment (id SERIAL PRIMARY KEY,@@ -192,12 +153,6 @@ CREATE UNIQUE INDEX idx_environment_unique_resource_id ON environment(resource_iALTER SEQUENCE environment_id_seq RESTART WITH 101;-CREATE TRIGGER update_environment_updated_ts-BEFORE-UPDATE- ON environment FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Policy-- policy stores the policies for each environment.-- Policies are associated with environments. Since we may have policies not associated with environment later, we name the table policy.@@ -221,12 +176,6 @@ CREATE UNIQUE INDEX idx_policy_unique_resource_type_resource_id_type ON policy(rALTER SEQUENCE policy_id_seq RESTART WITH 101;-CREATE TRIGGER update_policy_updated_ts-BEFORE-UPDATE- ON policy FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- ProjectCREATE TABLE project (id SERIAL PRIMARY KEY,@@ -270,12 +219,6 @@ VALUESALTER SEQUENCE project_id_seq RESTART WITH 101;-CREATE TRIGGER update_project_updated_ts-BEFORE-UPDATE- ON project FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Project memberCREATE TABLE project_member (id SERIAL PRIMARY KEY,@@ -294,12 +237,6 @@ CREATE INDEX idx_project_member_project_id ON project_member(project_id);ALTER SEQUENCE project_member_id_seq RESTART WITH 101;-CREATE TRIGGER update_project_member_updated_ts-BEFORE-UPDATE- ON project_member FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Project HookCREATE TABLE project_webhook (id SERIAL PRIMARY KEY,@@ -321,12 +258,6 @@ CREATE UNIQUE INDEX idx_project_webhook_unique_project_id_url ON project_webhookALTER SEQUENCE project_webhook_id_seq RESTART WITH 101;-CREATE TRIGGER update_project_webhook_updated_ts-BEFORE-UPDATE- ON project_webhook FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- InstanceCREATE TABLE instance (id SERIAL PRIMARY KEY,@@ -351,12 +282,6 @@ CREATE UNIQUE INDEX idx_instance_unique_resource_id ON instance(resource_id);ALTER SEQUENCE instance_id_seq RESTART WITH 101;-CREATE TRIGGER update_instance_updated_ts-BEFORE-UPDATE- ON instance FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Instance user stores the users for a particular instanceCREATE TABLE instance_user (id SERIAL PRIMARY KEY,@@ -374,12 +299,6 @@ ALTER SEQUENCE instance_user_id_seq RESTART WITH 101;CREATE UNIQUE INDEX idx_instance_user_unique_instance_id_name ON instance_user(instance_id, name);-CREATE TRIGGER update_instance_user_updated_ts-BEFORE-UPDATE- ON instance_user FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- db stores the databases for a particular instance-- data is synced periodically from the instanceCREATE TABLE db (@@ -411,12 +330,6 @@ CREATE INDEX idx_db_project_id ON db(project_id);ALTER SEQUENCE db_id_seq RESTART WITH 101;-CREATE TRIGGER update_db_updated_ts-BEFORE-UPDATE- ON db FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- db_schema stores the database schema metadata for a particular database.CREATE TABLE db_schema (id SERIAL PRIMARY KEY,@@ -435,12 +348,6 @@ CREATE UNIQUE INDEX idx_db_schema_unique_database_id ON db_schema(database_id);ALTER SEQUENCE db_schema_id_seq RESTART WITH 101;-CREATE TRIGGER update_db_schema_updated_ts-BEFORE-UPDATE- ON db_schema FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- data_source table stores the data source for a particular databaseCREATE TABLE data_source (id SERIAL PRIMARY KEY,@@ -467,12 +374,6 @@ CREATE UNIQUE INDEX idx_data_source_unique_instance_id_name ON data_source(instaALTER SEQUENCE data_source_id_seq RESTART WITH 101;-CREATE TRIGGER update_data_source_updated_ts-BEFORE-UPDATE- ON data_source FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-------------------------- Pipeline related BEGIN-- pipeline table@@ -489,12 +390,6 @@ CREATE TABLE pipeline (ALTER SEQUENCE pipeline_id_seq RESTART WITH 101;-CREATE TRIGGER update_pipeline_updated_ts-BEFORE-UPDATE- ON pipeline FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- stage table stores the stage for the pipelineCREATE TABLE stage (id SERIAL PRIMARY KEY,@@ -512,12 +407,6 @@ CREATE INDEX idx_stage_pipeline_id ON stage(pipeline_id);ALTER SEQUENCE stage_id_seq RESTART WITH 101;-CREATE TRIGGER update_stage_updated_ts-BEFORE-UPDATE- ON stage FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- task table stores the task for the stageCREATE TABLE task (id SERIAL PRIMARY KEY,@@ -546,12 +435,6 @@ CREATE INDEX idx_task_earliest_allowed_ts ON task(earliest_allowed_ts);ALTER SEQUENCE task_id_seq RESTART WITH 101;-CREATE TRIGGER update_task_updated_ts-BEFORE-UPDATE- ON task FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- task_dag describes task dependency relationship-- from_task_id blocks to_task_idCREATE TABLE task_dag (@@ -569,12 +452,6 @@ CREATE INDEX idx_task_dag_to_task_id ON task_dag(to_task_id);ALTER SEQUENCE task_dag_id_seq RESTART WITH 101;-CREATE TRIGGER update_task_dag_updated_ts-BEFORE-UPDATE- ON task_dag FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- task run table stores the task runCREATE TABLE task_run (id SERIAL PRIMARY KEY,@@ -598,12 +475,6 @@ CREATE UNIQUE INDEX uk_task_run_task_id_attempt ON task_run (task_id, attempt);ALTER SEQUENCE task_run_id_seq RESTART WITH 101;-CREATE TRIGGER update_task_run_updated_ts-BEFORE-UPDATE- ON task_run FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Pipeline related END------------------------- Plan related BEGIN@@ -627,12 +498,6 @@ CREATE INDEX idx_plan_pipeline_id ON plan(pipeline_id);ALTER SEQUENCE plan_id_seq RESTART WITH 101;-CREATE TRIGGER update_plan_updated_ts-BEFORE-UPDATE- ON plan FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE plan_check_run (id SERIAL PRIMARY KEY,creator_id INTEGER NOT NULL REFERENCES principal (id),@@ -651,12 +516,6 @@ CREATE INDEX idx_plan_check_run_plan_id ON plan_check_run (plan_id);ALTER SEQUENCE plan_check_run_id_seq RESTART WITH 101;-CREATE TRIGGER update_plan_check_run_updated_ts-BEFORE-UPDATE- ON plan_check_run FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Plan related END------------------------- issue@@ -696,12 +555,6 @@ CREATE INDEX idx_issue_ts_vector ON issue USING GIN(ts_vector);ALTER SEQUENCE issue_id_seq RESTART WITH 101;-CREATE TRIGGER update_issue_updated_ts-BEFORE-UPDATE- ON issue FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- stores the issue subscribers. Unlike other tables, it doesn't have row_status/creator_id/created_ts/updater_id/updated_ts.-- We use a separate table mainly because we can't leverage indexed query if the subscriber id is stored-- as a comma separated id list in the issue table.@@ -763,12 +616,6 @@ CREATE UNIQUE INDEX idx_instance_change_history_unique_instance_id_database_id_vALTER SEQUENCE instance_change_history_id_seq RESTART WITH 101;-CREATE TRIGGER update_instance_change_history_updated_ts-BEFORE-UPDATE- ON instance_change_history FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- activity table stores the activity for the container such as issueCREATE TABLE activity (id SERIAL PRIMARY KEY,@@ -793,12 +640,6 @@ CREATE INDEX idx_activity_created_ts ON activity(created_ts);ALTER SEQUENCE activity_id_seq RESTART WITH 101;-CREATE TRIGGER update_activity_updated_ts-BEFORE-UPDATE- ON activity FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE issue_comment (id BIGSERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',@@ -814,12 +655,6 @@ CREATE INDEX idx_issue_comment_issue_id ON issue_comment(issue_id);ALTER SEQUENCE issue_comment_id_seq RESTART WITH 101;-CREATE TRIGGER update_issue_comment_updated_ts-BEFORE-UPDATE- ON issue_comment FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE query_history (id BIGSERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',@@ -855,12 +690,6 @@ CREATE UNIQUE INDEX idx_vcs_unique_resource_id ON vcs(resource_id);ALTER SEQUENCE vcs_id_seq RESTART WITH 101;-CREATE TRIGGER update_vcs_updated_ts-BEFORE-UPDATE- ON vcs FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- vcs_connector table stores vcs connectors for a projectCREATE TABLE vcs_connector (id SERIAL PRIMARY KEY,@@ -879,12 +708,6 @@ CREATE UNIQUE INDEX idx_vcs_connector_unique_project_id_resource_id ON vcs_conneALTER SEQUENCE vcs_connector_id_seq RESTART WITH 101;-CREATE TRIGGER update_vcs_connector_updated_ts-BEFORE-UPDATE- ON vcs_connector FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Anomaly-- anomaly stores various anomalies found by the scanner.-- For now, anomaly can be associated with a particular instance or database.@@ -907,12 +730,6 @@ CREATE INDEX idx_anomaly_database_id_row_status_type ON anomaly(database_id, rowALTER SEQUENCE anomaly_id_seq RESTART WITH 101;-CREATE TRIGGER update_anomaly_updated_ts-BEFORE-UPDATE- ON anomaly FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- Deployment Configuration.-- deployment_config stores deployment configurations at project level.CREATE TABLE deployment_config (@@ -931,12 +748,6 @@ CREATE UNIQUE INDEX idx_deployment_config_unique_project_id ON deployment_configALTER SEQUENCE deployment_config_id_seq RESTART WITH 101;-CREATE TRIGGER update_deployment_config_updated_ts-BEFORE-UPDATE- ON deployment_config FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- sheet table stores general statements.CREATE TABLE sheet (id SERIAL PRIMARY KEY,@@ -964,12 +775,6 @@ CREATE INDEX idx_sheet_database_id_row_status ON sheet(database_id, row_status);ALTER SEQUENCE sheet_id_seq RESTART WITH 101;-CREATE TRIGGER update_sheet_updated_ts-BEFORE-UPDATE- ON sheet FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE worksheet (id SERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',@@ -989,12 +794,6 @@ CREATE INDEX idx_worksheet_creator_id_project_id ON worksheet(creator_id, projecALTER SEQUENCE worksheet_id_seq RESTART WITH 101;-CREATE TRIGGER update_worksheet_updated_ts-BEFORE-UPDATE- ON worksheet FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- worksheet_organizer table stores the sheet status for a principal.CREATE TABLE worksheet_organizer (id SERIAL PRIMARY KEY,@@ -1024,13 +823,6 @@ CREATE INDEX idx_external_approval_row_status_issue_id ON external_approval(row_ALTER SEQUENCE external_approval_id_seq RESTART WITH 101;-CREATE TRIGGER update_external_approval_updated_ts-BEFORE-UPDATE- ON external_approval FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();---- risk stores the definition of a risk.CREATE TABLE risk (id BIGSERIAL PRIMARY KEY,@@ -1049,12 +841,6 @@ CREATE TABLE risk (ALTER SEQUENCE risk_id_seq RESTART WITH 101;-CREATE TRIGGER update_risk_updated_ts-BEFORE-UPDATE- ON risk FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- slow_query stores slow query statistics for each database.CREATE TABLE slow_query (id SERIAL PRIMARY KEY,@@ -1081,12 +867,6 @@ CREATE INDEX idx_slow_query_instance_id_log_date_ts ON slow_query (instance_id,ALTER SEQUENCE slow_query_id_seq RESTART WITH 101;-CREATE TRIGGER update_slow_query_updated_ts-BEFORE-UPDATE- ON slow_query FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE db_group (id BIGSERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',@@ -1106,12 +886,6 @@ CREATE UNIQUE INDEX idx_db_group_unique_project_id_placeholder ON db_group(projeALTER SEQUENCE db_group_id_seq RESTART WITH 101;-CREATE TRIGGER update_db_group_updated_ts-BEFORE-UPDATE- ON db_group FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE schema_group (id BIGSERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',@@ -1131,12 +905,6 @@ CREATE UNIQUE INDEX idx_schema_group_unique_db_group_id_placeholder ON schema_grALTER SEQUENCE schema_group_id_seq RESTART WITH 101;-CREATE TRIGGER update_schema_group_updated_ts-BEFORE-UPDATE- ON schema_group FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();--- changelist table stores project changelists.CREATE TABLE changelist (id SERIAL PRIMARY KEY,@@ -1154,12 +922,6 @@ CREATE UNIQUE INDEX idx_changelist_project_id_name ON changelist(project_id, namALTER SEQUENCE changelist_id_seq RESTART WITH 101;-CREATE TRIGGER update_changelist_updated_ts-BEFORE-UPDATE- ON changelist FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE branch (id SERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',@@ -1184,12 +946,6 @@ CREATE INDEX idx_branch_reconcile_state ON branch(reconcile_state);ALTER SEQUENCE branch_id_seq RESTART WITH 101;-CREATE TRIGGER update_branch_updated_ts-BEFORE-UPDATE- ON branch FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();-CREATE TABLE export_archive (id SERIAL PRIMARY KEY,created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 62041e50d6..3458a452cc 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -230,5 +230,5 @@ func TestMigrationCompatibility(t *testing.T) {func TestGetCutoffVersion(t *testing.T) {releaseVersion, err := getProdCutoffVersion()require.NoError(t, err)- require.Equal(t, semver.MustParse("2.15.19"), releaseVersion)+ require.Equal(t, semver.MustParse("2.15.20"), releaseVersion)}diff --git a/backend/store/activity.go b/backend/store/activity.goindex 4a37d638ab..35150ff0c9 100644--- a/backend/store/activity.go+++ b/backend/store/activity.go@@ -6,6 +6,7 @@ import ("encoding/json""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -324,7 +325,7 @@ func (s *Store) UpdateActivityV2(ctx context.Context, update *UpdateActivityMess}defer tx.Rollback()- set, args := []string{}, []any{}+ set, args := []string{"updated_ts = $1"}, []any{time.Now().Unix()}if v := update.Comment; v != nil {set, args = append(set, fmt.Sprintf("comment = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/anomaly.go b/backend/store/anomaly.goindex 0c49c2ec2e..586cc85a4a 100644--- a/backend/store/anomaly.go+++ b/backend/store/anomaly.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors"@@ -317,8 +318,7 @@ func updateAnomalyV2(ctx context.Context, tx *Tx, principalUID int, update *updaif update.Payload == "" {update.Payload = "{}"}- set, args := []string{"updater_id = $1"}, []any{principalUID}- set, args = append(set, "payload = $2"), append(args, update.Payload)+ set, args := []string{"updater_id = $1", "updated_ts = $2", "payload = $3"}, []any{principalUID, time.Now().Unix(), update.Payload}args = append(args, update.UID)// Execute update query with RETURNING.diff --git a/backend/store/branch.go b/backend/store/branch.goindex e91b5419c0..bdb568f848 100644--- a/backend/store/branch.go+++ b/backend/store/branch.go@@ -295,7 +295,7 @@ func (s *Store) UpdateBranch(ctx context.Context, update *UpdateBranchMessage) ereturn errors.Wrapf(err, "failed to begin transaction")}- set, args := []string{"updater_id = $1"}, []any{update.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{update.UpdaterID, time.Now().Unix()}if v := update.Base; v != nil {base, err := protojson.Marshal(v)if err != nil {diff --git a/backend/store/changelist.go b/backend/store/changelist.goindex 34c977d998..733517dede 100644--- a/backend/store/changelist.go+++ b/backend/store/changelist.go@@ -202,7 +202,7 @@ func (s *Store) UpdateChangelist(ctx context.Context, update *UpdateChangelistMereturn errors.Wrapf(err, "failed to begin transaction")}- set, args := []string{"updater_id = $1"}, []any{update.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{update.UpdaterID, time.Now().Unix()}if v := update.Payload; v != nil {payload, err := protojson.Marshal(update.Payload)if err != nil {diff --git a/backend/store/data_source.go b/backend/store/data_source.goindex dee976d93c..aae2fc0ba7 100644--- a/backend/store/data_source.go+++ b/backend/store/data_source.go@@ -4,6 +4,7 @@ import ("context""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -228,7 +229,7 @@ func (s *Store) RemoveDataSourceV2(ctx context.Context, instanceUID int, instanc// UpdateDataSourceV2 updates a data source and returns the instance.func (s *Store) UpdateDataSourceV2(ctx context.Context, patch *UpdateDataSourceMessage) error {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.Username; v != nil {set, args = append(set, fmt.Sprintf("username = $%d", len(args)+1)), append(args, *v)diff --git a/backend/store/database.go b/backend/store/database.goindex 0e02d599c2..459bdf3f2b 100644--- a/backend/store/database.go+++ b/backend/store/database.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -330,7 +331,7 @@ func (s *Store) UpdateDatabase(ctx context.Context, patch *UpdateDatabaseMessagereturn nil, err}- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterID, time.Now().Unix()}if v := patch.ProjectID; v != nil {project, err := s.GetProjectV2(ctx, &FindProjectMessage{ResourceID: patch.ProjectID})if err != nil {diff --git a/backend/store/database_group.go b/backend/store/database_group.goindex c315b7cd56..26909e309b 100644--- a/backend/store/database_group.go+++ b/backend/store/database_group.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/genproto/googleapis/type/expr"@@ -197,7 +198,7 @@ func (*Store) listDatabaseGroupImpl(ctx context.Context, tx *Tx, find *FindDatab// UpdateDatabaseGroup updates a database group.func (s *Store) UpdateDatabaseGroup(ctx context.Context, updaterPrincipalID int, databaseGroupUID int64, patch *UpdateDatabaseGroupMessage) (*DatabaseGroupMessage, error) {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterPrincipalID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterPrincipalID, time.Now().Unix()}if v := patch.Placeholder; v != nil {set, args = append(set, fmt.Sprintf("placeholder = $%d", len(args)+1)), append(args, *v)}@@ -486,7 +487,7 @@ func (*Store) listSchemaGroupsImpl(ctx context.Context, tx *Tx, find *FindSchema// UpdateSchemaGroup updates a schema group.func (s *Store) UpdateSchemaGroup(ctx context.Context, updaterPrincipalID int, schemaGroupUID int64, patch *UpdateSchemaGroupMessage) (*SchemaGroupMessage, error) {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterPrincipalID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterPrincipalID, time.Now().Unix()}if v := patch.Placeholder; v != nil {set, args = append(set, fmt.Sprintf("placeholder = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/db_schema.go b/backend/store/db_schema.goindex ca6df2fd7c..04504377e5 100644--- a/backend/store/db_schema.go+++ b/backend/store/db_schema.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""google.golang.org/protobuf/encoding/protojson"@@ -121,7 +122,7 @@ func (s *Store) UpsertDBSchema(ctx context.Context, databaseID int, dbSchema *mo// UpdateDBSchema updates a database schema.func (s *Store) UpdateDBSchema(ctx context.Context, databaseID int, patch *UpdateDBSchemaMessage, updaterID int) error {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterID, time.Now().Unix()}if v := patch.Config; v != nil {bytes, err := protojson.Marshal(v)if err != nil {diff --git a/backend/store/deploy.go b/backend/store/deploy.goindex 8a8d9afbd3..e41cafff92 100644--- a/backend/store/deploy.go+++ b/backend/store/deploy.go@@ -6,6 +6,7 @@ import ("encoding/json""fmt""strings"+ "time""github.com/pkg/errors"@@ -184,13 +185,15 @@ func (s *Store) UpsertDeploymentConfigV2(ctx context.Context, projectUID, princiINSERT INTO deployment_config (creator_id,updater_id,+ updated_ts,project_id,name,config)- VALUES ($1, $2, $3, $4, $5)+ VALUES ($1, $2, $3, $4, $5, $6)ON CONFLICT(project_id) DO UPDATE SETupdater_id = excluded.updater_id,+ updated_ts = excluded.updated_ts,name = excluded.name,config = excluded.configRETURNING id, name, config@@ -206,6 +209,7 @@ func (s *Store) UpsertDeploymentConfigV2(ctx context.Context, projectUID, princiif err := tx.QueryRowContext(ctx, query,principalUID,principalUID,+ time.Now().Unix(),projectUID,upsert.Name,payload,diff --git a/backend/store/environment.go b/backend/store/environment.goindex f817a45d1b..1959236b3d 100644--- a/backend/store/environment.go+++ b/backend/store/environment.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors"@@ -173,7 +174,7 @@ func (s *Store) CreateEnvironmentV2(ctx context.Context, create *EnvironmentMess// UpdateEnvironmentV2 updates an environment.func (s *Store) UpdateEnvironmentV2(ctx context.Context, environmentID string, patch *UpdateEnvironmentMessage, updaterID int) (*EnvironmentMessage, error) {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterID, time.Now().Unix()}if v := patch.Name; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/idp.go b/backend/store/idp.goindex 982e7bcc30..cd63c7c0d0 100644--- a/backend/store/idp.go+++ b/backend/store/idp.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -188,7 +189,7 @@ func (s *Store) UpdateIdentityProvider(ctx context.Context, patch *UpdateIdentit}func (*Store) updateIdentityProviderImpl(ctx context.Context, tx *Tx, patch *UpdateIdentityProviderMessage) (*IdentityProviderMessage, error) {- set, args := []string{}, []any{}+ set, args := []string{"updated_ts = $1"}, []any{time.Now().Unix()}if v := patch.Title; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/instance.go b/backend/store/instance.goindex f550bff94a..8d6542d222 100644--- a/backend/store/instance.go+++ b/backend/store/instance.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/grpc/codes"@@ -230,7 +231,7 @@ func (s *Store) UpdateInstanceV2(ctx context.Context, patch *UpdateInstanceMessa}}- set, args, where := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}, []string{}+ set, args, where := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}, []string{}if v := patch.Title; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/instance_user.go b/backend/store/instance_user.goindex de780ba511..5ed38a62ad 100644--- a/backend/store/instance_user.go+++ b/backend/store/instance_user.go@@ -4,6 +4,7 @@ import ("context""fmt""strings"+ "time""github.com/pkg/errors"@@ -94,13 +95,14 @@ func (s *Store) UpsertInstanceUsers(ctx context.Context, instanceUID int, instanargs := []any{}var placeholders []stringfor i, instanceUser := range upserts {- args = append(args, api.SystemBotID, api.SystemBotID, instanceUID, instanceUser.Name, instanceUser.Grant)- placeholders = append(placeholders, fmt.Sprintf("($%d, $%d, $%d, $%d, $%d)", 5*i+1, 5*i+2, 5*i+3, 5*i+4, 5*i+5))+ args = append(args, api.SystemBotID, api.SystemBotID, time.Now().Unix(), instanceUID, instanceUser.Name, instanceUser.Grant)+ placeholders = append(placeholders, fmt.Sprintf("($%d, $%d, $%d, $%d, $%d, $%d)", 6*i+1, 6*i+2, 6*i+3, 6*i+4, 6*i+5, 6*i+6))}query := fmt.Sprintf(`INSERT INTO instance_user (creator_id,updater_id,+ updated_ts,instance_id,name,"grant"diff --git a/backend/store/issue.go b/backend/store/issue.goindex 262252df90..51881fe5f4 100644--- a/backend/store/issue.go+++ b/backend/store/issue.go@@ -234,8 +234,7 @@ func (s *Store) UpdateIssueV2(ctx context.Context, uid int, patch *UpdateIssueMereturn nil, err}- set, args := []string{"updater_id = $1"}, []any{updaterID}-+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterID, time.Now().Unix()}if v := patch.PipelineUID; v != nil {set, args = append(set, fmt.Sprintf("pipeline_id = $%d", len(args)+1)), append(args, *v)}@@ -710,8 +709,6 @@ func (s *Store) BackfillIssueTsVector(ctx context.Context) error {SET ts_vector = $1WHERE id = $2`- disableTriggerStatement := "ALTER TABLE issue DISABLE TRIGGER update_issue_updated_ts"- enableTriggerStatement := "ALTER TABLE issue ENABLE TRIGGER update_issue_updated_ts"tx, err := s.db.BeginTx(ctx, nil)if err != nil {@@ -719,10 +716,6 @@ func (s *Store) BackfillIssueTsVector(ctx context.Context) error {}defer tx.Rollback()- if _, err := tx.ExecContext(ctx, disableTriggerStatement); err != nil {- return errors.Wrapf(err, "failed to disable trigger")- }-for {var issues []*IssueMessageif err := func() error {@@ -759,10 +752,6 @@ func (s *Store) BackfillIssueTsVector(ctx context.Context) error {}}- if _, err := tx.ExecContext(ctx, enableTriggerStatement); err != nil {- return errors.Wrapf(err, "failed to enable trigger")- }-if err := tx.Commit(); err != nil {return errors.Wrapf(err, "failed to commit")}diff --git a/backend/store/issue_comment.go b/backend/store/issue_comment.goindex 20275a3f2b..05f7142e05 100644--- a/backend/store/issue_comment.go+++ b/backend/store/issue_comment.go@@ -4,6 +4,7 @@ import ("context""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -152,10 +153,11 @@ func (s *Store) UpdateIssueComment(ctx context.Context, comment string, uid int,UPDATE issue_commentSETupdater_id = $1,- payload = payload || jsonb_build_object('comment', $2)- WHERE id = $3+ updated_ts = $2+ payload = payload || jsonb_build_object('comment', $3)+ WHERE id = $4`- if _, err := s.db.db.ExecContext(ctx, query, updaterUID, comment, uid); err != nil {+ if _, err := s.db.db.ExecContext(ctx, query, updaterUID, time.Now().Unix(), comment, uid); err != nil {return errors.Wrapf(err, "failed to update issue comment")}return nildiff --git a/backend/store/plan.go b/backend/store/plan.goindex 26c67f4443..41618e21b0 100644--- a/backend/store/plan.go+++ b/backend/store/plan.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -207,7 +208,7 @@ func (s *Store) ListPlans(ctx context.Context, find *FindPlanMessage) ([]*PlanMe// UpdatePlan updates an existing plan.func (s *Store) UpdatePlan(ctx context.Context, patch *UpdatePlanMessage) error {- set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.Config; v != nil {config, err := protojson.Marshal(v)if err != nil {diff --git a/backend/store/plan_check_run.go b/backend/store/plan_check_run.goindex 3fa5fd5d22..295f51fa97 100644--- a/backend/store/plan_check_run.go+++ b/backend/store/plan_check_run.go@@ -4,6 +4,7 @@ import ("context""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -206,10 +207,11 @@ func (s *Store) UpdatePlanCheckRun(ctx context.Context, updaterUID int, status PUPDATE plan_check_runSETupdater_id = $1,- status = $2,- result = $3- WHERE id = $4`- if _, err := s.db.db.ExecContext(ctx, query, updaterUID, status, resultBytes, uid); err != nil {+ updated_ts = $2,+ status = $3,+ result = $4+ WHERE id = $5`+ if _, err := s.db.db.ExecContext(ctx, query, updaterUID, time.Now().Unix(), status, resultBytes, uid); err != nil {return errors.Wrapf(err, "failed to update plan check run")}return nildiff --git a/backend/store/policy.go b/backend/store/policy.goindex 0b29ef2386..0475614814 100644--- a/backend/store/policy.go+++ b/backend/store/policy.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -279,7 +280,7 @@ func (s *Store) CreatePolicyV2(ctx context.Context, create *PolicyMessage, creat// UpdatePolicyV2 updates the policy.func (s *Store) UpdatePolicyV2(ctx context.Context, patch *UpdatePolicyMessage) (*PolicyMessage, error) {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.InheritFromParent; v != nil {set, args = append(set, fmt.Sprintf("inherit_from_parent = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/principal.go b/backend/store/principal.goindex 8af692ab69..f42501ad8a 100644--- a/backend/store/principal.go+++ b/backend/store/principal.go@@ -4,6 +4,7 @@ import ("context""fmt""strings"+ "time""github.com/jackc/pgtype""github.com/pkg/errors"@@ -326,7 +327,7 @@ func (s *Store) UpdateUser(ctx context.Context, userID int, patch *UpdateUserMesreturn nil, errors.Errorf("cannot update system bot")}- principalSet, principalArgs := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}+ principalSet, principalArgs := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterID, time.Now().Unix()}if v := patch.Delete; v != nil {rowStatus := api.Normalif *patch.Delete {diff --git a/backend/store/project.go b/backend/store/project.goindex 024d0a1f9c..ab060c88f6 100644--- a/backend/store/project.go+++ b/backend/store/project.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -223,7 +224,7 @@ func (s *Store) UpdateProjectV2(ctx context.Context, patch *UpdateProjectMessage}func updateProjectImplV2(ctx context.Context, tx *Tx, patch *UpdateProjectMessage) error {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.Title; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/project_webhook.go b/backend/store/project_webhook.goindex 473e972efd..48f7571386 100644--- a/backend/store/project_webhook.go+++ b/backend/store/project_webhook.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/jackc/pgtype""github.com/pkg/errors"@@ -154,8 +155,7 @@ func (s *Store) UpdateProjectWebhookV2(ctx context.Context, principalUID int, prif err != nil {return nil, errors.Wrapf(err, "failed to begin transaction")}- // Build UPDATE clause.- set, args := []string{"updater_id = $1"}, []any{principalUID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{principalUID, time.Now().Unix()}if v := update.Title; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/risk.go b/backend/store/risk.goindex 46c68e5052..f426c39946 100644--- a/backend/store/risk.go+++ b/backend/store/risk.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/genproto/googleapis/type/expr"@@ -222,7 +223,7 @@ func (s *Store) CreateRisk(ctx context.Context, risk *RiskMessage, creatorID int// UpdateRisk updates a risk.func (s *Store) UpdateRisk(ctx context.Context, patch *UpdateRiskMessage, id int64, updaterID int) (*RiskMessage, error) {- set, args := []string{"updater_id = $1"}, []any{updaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{updaterID, time.Now().Unix()}if v := patch.Name; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/role.go b/backend/store/role.goindex f691a28bb9..a514672b7c 100644--- a/backend/store/role.go+++ b/backend/store/role.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""google.golang.org/protobuf/encoding/protojson"@@ -173,7 +174,7 @@ func (s *Store) ListRoles(ctx context.Context) ([]*RoleMessage, error) {// UpdateRole updates an existing role.func (s *Store) UpdateRole(ctx context.Context, patch *UpdateRoleMessage) (*RoleMessage, error) {- set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.Name; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/setting.go b/backend/store/setting.goindex 277b0205d9..b4e4a08d13 100644--- a/backend/store/setting.go+++ b/backend/store/setting.go@@ -6,6 +6,7 @@ import ("encoding/json""fmt""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -251,9 +252,9 @@ func (s *Store) ListSettingV2(ctx context.Context, find *FindSettingMessage) ([]// UpsertSettingV2 upserts the setting by name.func (s *Store) UpsertSettingV2(ctx context.Context, update *SetSettingMessage, principalUID int) (*SettingMessage, error) {- fields := []string{"creator_id", "updater_id", "name", "value"}- updateFields := []string{"value = EXCLUDED.value", "updater_id = EXCLUDED.updater_id"}- valuePlaceholders, args := []string{"$1", "$2", "$3", "$4"}, []any{principalUID, principalUID, update.Name, update.Value}+ fields := []string{"creator_id", "updater_id", "updated_ts", "name", "value"}+ updateFields := []string{"value = EXCLUDED.value", "updater_id = EXCLUDED.updater_id", "updated_ts = EXCLUDED.updated_ts"}+ valuePlaceholders, args := []string{"$1", "$2", "$3", "$4", "$5"}, []any{principalUID, principalUID, time.Now().Unix(), update.Name, update.Value}if v := update.Description; v != nil {fields = append(fields, "description")diff --git a/backend/store/sheet.go b/backend/store/sheet.goindex 95e52f8883..05cee55022 100644--- a/backend/store/sheet.go+++ b/backend/store/sheet.go@@ -274,7 +274,7 @@ func (s *Store) PatchSheet(ctx context.Context, patch *PatchSheetMessage) (*Shee// patchSheetImpl updates a sheet's name/statement/payload/database_id/project_id.func patchSheetImpl(ctx context.Context, tx *Tx, patch *PatchSheetMessage) (*SheetMessage, error) {- set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.Statement; v != nil {set, args = append(set, fmt.Sprintf("statement = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/task.go b/backend/store/task.goindex fb1be086dd..c8784d331f 100644--- a/backend/store/task.go+++ b/backend/store/task.go@@ -8,6 +8,7 @@ import ("math""sort""strings"+ "time""github.com/jackc/pgtype""github.com/pkg/errors"@@ -285,7 +286,7 @@ func (s *Store) ListTasks(ctx context.Context, find *api.TaskFind) ([]*TaskMessa// UpdateTaskV2 updates an existing task.// Returns ENOTFOUND if task does not exist.func (s *Store) UpdateTaskV2(ctx context.Context, patch *api.TaskPatch) (*TaskMessage, error) {- set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.DatabaseID; v != nil {set, args = append(set, fmt.Sprintf("database_id = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/task_run.go b/backend/store/task_run.goindex d62d1c0905..4ff265a67b 100644--- a/backend/store/task_run.go+++ b/backend/store/task_run.go@@ -6,6 +6,7 @@ import ("fmt""sort""strings"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -332,8 +333,7 @@ func (*Store) createTaskRunImpl(ctx context.Context, tx *Tx, create *TaskRunMess// patchTaskRunStatusImpl updates a taskRun status. Returns the new state of the taskRun after update.func (*Store) patchTaskRunStatusImpl(ctx context.Context, tx *Tx, patch *TaskRunStatusPatch) (*TaskRunMessage, error) {- set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}- set, args = append(set, "status = $2"), append(args, patch.Status)+ set, args := []string{"updater_id = $1", "updated_ts = $2", "status = $3"}, []any{patch.UpdaterID, time.Now().Unix(), patch.Status}if v := patch.Code; v != nil {set, args = append(set, fmt.Sprintf("code = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/vcs_connector.go b/backend/store/vcs_connector.goindex e4f3fb28df..0d2cfde2f9 100644--- a/backend/store/vcs_connector.go+++ b/backend/store/vcs_connector.go@@ -193,7 +193,7 @@ func (s *Store) CreateVCSConnector(ctx context.Context, create *VCSConnectorMess// UpdateVCSConnector updates a VCS connector.func (s *Store) UpdateVCSConnector(ctx context.Context, update *UpdateVCSConnectorMessage) error {- set, args := []string{"updater_id = $1"}, []any{update.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{update.UpdaterID, time.Now().Unix()}var payloadSet []stringif v := update.Branch; v != nil {diff --git a/backend/store/vcs_provider.go b/backend/store/vcs_provider.goindex 9540fed914..7088fe36c2 100644--- a/backend/store/vcs_provider.go+++ b/backend/store/vcs_provider.go@@ -5,6 +5,7 @@ import ("database/sql""fmt""strings"+ "time""github.com/pkg/errors"@@ -147,8 +148,7 @@ func (s *Store) CreateVCSProvider(ctx context.Context, principalUID int, create// UpdateVCSProvider updates an VCS provider.func (s *Store) UpdateVCSProvider(ctx context.Context, principalUID int, vcsProviderUID int, update *UpdateVCSProviderMessage) (*VCSProviderMessage, error) {- // Build UPDATE clause.- set, args := []string{"updater_id = $1"}, []any{principalUID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{principalUID, time.Now().Unix()}if v := update.Name; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}diff --git a/backend/store/worksheet.go b/backend/store/worksheet.goindex d90f0b740b..02400227bc 100644--- a/backend/store/worksheet.go+++ b/backend/store/worksheet.go@@ -306,7 +306,7 @@ func (s *Store) DeleteWorkSheet(ctx context.Context, sheetUID int) error {// patchWorkSheetImpl updates a sheet's name/statement/visibility/database_id/project_id.func patchWorkSheetImpl(ctx context.Context, tx *Tx, patch *PatchWorkSheetMessage) error {- set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}+ set, args := []string{"updater_id = $1", "updated_ts = $2"}, []any{patch.UpdaterID, time.Now().Unix()}if v := patch.Title; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}