From fee780cb81a3763ada7a015e34fb01093f313cfe Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 3 Apr 2026 11:29:08 -0400 Subject: [PATCH] Add siem to migration --- server/setup/scriptsSqlite/1.17.0.ts | 56 +++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/server/setup/scriptsSqlite/1.17.0.ts b/server/setup/scriptsSqlite/1.17.0.ts index 28877f16e..28929fc63 100644 --- a/server/setup/scriptsSqlite/1.17.0.ts +++ b/server/setup/scriptsSqlite/1.17.0.ts @@ -76,9 +76,15 @@ export default async function migration() { ` ).run(); - db.prepare(`CREATE INDEX 'idx_accessAuditLog_startedAt' ON 'connectionAuditLog' ('startedAt');`).run(); - db.prepare(`CREATE INDEX 'idx_accessAuditLog_org_startedAt' ON 'connectionAuditLog' ('orgId','startedAt');`).run(); - db.prepare(`CREATE INDEX 'idx_accessAuditLog_siteResourceId' ON 'connectionAuditLog' ('siteResourceId');`).run(); + db.prepare( + `CREATE INDEX 'idx_accessAuditLog_startedAt' ON 'connectionAuditLog' ('startedAt');` + ).run(); + db.prepare( + `CREATE INDEX 'idx_accessAuditLog_org_startedAt' ON 'connectionAuditLog' ('orgId','startedAt');` + ).run(); + db.prepare( + `CREATE INDEX 'idx_accessAuditLog_siteResourceId' ON 'connectionAuditLog' ('siteResourceId');` + ).run(); db.prepare( ` @@ -168,6 +174,42 @@ export default async function migration() { ); ` ).run(); + + db.prepare( + ` + CREATE TABLE 'eventStreamingCursors' ( + 'cursorId' integer PRIMARY KEY AUTOINCREMENT NOT NULL, + 'destinationId' integer NOT NULL, + 'logType' text NOT NULL, + 'lastSentId' integer DEFAULT 0 NOT NULL, + 'lastSentAt' integer, + FOREIGN KEY ('destinationId') REFERENCES 'eventStreamingDestinations'('destinationId') ON UPDATE no action ON DELETE cascade + ); + ` + ).run(); + db.prepare( + ` + CREATE UNIQUE INDEX 'idx_eventStreamingCursors_dest_type' ON 'eventStreamingCursors' ('destinationId','logType');--> statement-breakpoint + ` + ).run(); + db.prepare( + ` + CREATE TABLE 'eventStreamingDestinations' ( + 'destinationId' integer PRIMARY KEY AUTOINCREMENT NOT NULL, + 'orgId' text NOT NULL, + 'sendConnectionLogs' integer DEFAULT false NOT NULL, + 'sendRequestLogs' integer DEFAULT false NOT NULL, + 'sendActionLogs' integer DEFAULT false NOT NULL, + 'sendAccessLogs' integer DEFAULT false NOT NULL, + 'type' text NOT NULL, + 'config' text NOT NULL, + 'enabled' integer DEFAULT true NOT NULL, + 'createdAt' integer NOT NULL, + 'updatedAt' integer NOT NULL, + FOREIGN KEY ('orgId') REFERENCES 'orgs'('orgId') ON UPDATE no action ON DELETE cascade + ); + ` + ).run(); db.prepare( `INSERT INTO '__new_userInvites'("inviteId", "orgId", "email", "expiresAt", "token") SELECT "inviteId", "orgId", "email", "expiresAt", "token" FROM 'userInvites';` ).run(); @@ -191,8 +233,12 @@ export default async function migration() { `ALTER TABLE 'user' ADD 'marketingEmailConsent' integer DEFAULT false;` ).run(); db.prepare(`ALTER TABLE 'user' ADD 'locale' text;`).run(); - db.prepare(`ALTER TABLE 'siteProvisioningKeys' ADD COLUMN 'approveNewSites' integer DEFAULT 1 NOT NULL;`).run(); - db.prepare(`ALTER TABLE 'sites' ADD COLUMN 'status' text DEFAULT 'approved';`).run(); + db.prepare( + `ALTER TABLE 'siteProvisioningKeys' ADD COLUMN 'approveNewSites' integer DEFAULT 1 NOT NULL;` + ).run(); + db.prepare( + `ALTER TABLE 'sites' ADD COLUMN 'status' text DEFAULT 'approved';` + ).run(); })(); db.pragma("foreign_keys = ON");