Skip to content

Commit 4a8271b

Browse files
hvn2k1claude
andauthored
feat(migration): add organization_id column to audit_log (#2789)
Adds an organization_id column and (organization_id, timestamp DESC) index to the audit_log table on both MySQL and Postgres, so organization-level events can be stored there with an empty environment_id and read by organization admins. Step 1 of #1982. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 27448d8 commit 4a8271b

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Modify "audit_log" table: organization-level events are stored here with an
2+
-- empty environment_id, so organization admins can read their own activity.
3+
ALTER TABLE `audit_log` ADD COLUMN `organization_id` varchar(255) NOT NULL DEFAULT '', ALGORITHM=INSTANT;
4+
CREATE INDEX `idx_organization_id_timestamp_desc` ON `audit_log` (`organization_id`, `timestamp` DESC);

migration/mysql/atlas.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:8YDpIU578LqzbUEvkNKDitZCF1LqIotUqMUsDTn5g08=
1+
h1:sS2p63rku0jPZajD6/sreQgblM6HPitbdC5vlWn+gNE=
22
20240626022133_initialization.sql h1:reSmqMhqnsrdIdPU2ezv/PXSL0COlRFX4gQA4U3/wMo=
33
20240708065726_update_audit_log_table.sql h1:fi8Xxw4WfSlHDyvq2Ni/8JUiZW8z/0qWWyWm6jFdUy8=
44
20240815043128_update_auto_ops_rule_table.sql h1:IKSW9W/XO6SWAYl5WPLJSg6KdsfcZ3rfQhIrf7aOnYc=
@@ -43,3 +43,4 @@ h1:8YDpIU578LqzbUEvkNKDitZCF1LqIotUqMUsDTn5g08=
4343
20260514000000_update_feature_variation_value_schema.sql h1:ocGacenoNr4+sVeCeWASFDnUn+Sn2n04XmZpSf+82qM=
4444
20260713000000_create_notification_tables.sql h1:87SKJUcoNMMv48953z5QyaS9c/AxzJamnf+SZ6/SMJU=
4545
20260728000000_add_notification_deleted.sql h1:yky/5yXtjVf4Vl9si/FJ5ODUSPzjC1NfUsyfLCTh97I=
46+
20260826000000_add_audit_log_organization_id.sql h1:rgjKMBWwGhPyBpm7UrSaQMNjW+YuMWpqD3ELK9rZaWo=
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- atlas:txmode none
2+
3+
-- Modify "audit_log" table: organization-level events are stored here with an
4+
-- empty environment_id, so organization admins can read their own activity.
5+
ALTER TABLE audit_log ADD COLUMN organization_id VARCHAR(255) NOT NULL DEFAULT '';
6+
CREATE INDEX CONCURRENTLY idx_audit_log_organization_timestamp ON audit_log (organization_id, timestamp DESC);

migration/postgres/atlas.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
h1:s6kmbtFcVifKk1JOyBlaUyVfQtEFuVNgbbGIlTM7A10=
1+
h1:lS18LuoPXqICDLNHWc+AfUWz0jFwtTggjgnjGw/z9pA=
22
20260226174000_initialization.sql h1:orWPjklxeOP046jFps+1UhJDdaSDPwDjlODiSe/479c=
33
20260514000000_update_feature_variation_value_schema.sql h1:Jp91HETgQvAvqNGTgSBip8ipx3aAI5C4Tsa2z8eplB4=
44
20260713000000_create_notification_tables.sql h1:TqsueyglKP41Towy2FsYTGyxI3+h4bRbpGS4MZLLNhw=
55
20260728000000_add_notification_deleted.sql h1:OqtTB/u1YAJXjuhwfCJjfTfuNuaLtSvbUvbXD/82L6E=
6+
20260826000000_add_audit_log_organization_id.sql h1:/o7AtAf2nIjI3jkKtmXn5BuR+odCMvNkGoIikRGGxZg=

0 commit comments

Comments
 (0)