mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-08-29 18:31:33 +00:00
* groundwork for postgres and mysql backends #1127 made the repository layer dialect-agnostic. This adds the pieces needed to actually target a second engine, as a foundation only — nothing is wired up and sqlite remains the sole runtime path. - DatabaseDialect covers sqlite, postgres and mysql, resolved from DATABASE_DIALECT and defaulting to sqlite so nothing changes for existing deployments or the desktop build - a column kit holding the per-dialect type choices in one file: booleans are integers on sqlite and native elsewhere, autoincrement differs three ways, and MySQL cannot index unbounded TEXT so key columns need varchar - settings and users declared for all three dialects as a proof slice, chosen because between them they use every construct the real schema does - pg and mysql2 added as dependencies The tests build real queries for all three engines without a server, asserting identifier quoting, placeholder style and boolean storage, so the property the repositories depend on is verified rather than assumed. * verify foreign keys and unique constraints port across dialects The first slice only covered plain columns. The real schema also has 92 foreign keys (80 cascade, 12 set null) and 14 unique columns, so the approach is only viable if those survive the port. Adds audit_logs and ssh_folders to the proof slice: one nullable reference with ON DELETE SET NULL, one required reference with ON DELETE CASCADE, a unique column, and an autoincrement surrogate key — which is spelled three different ways underneath (integer primary key autoincrement, serial, int auto_increment). All of it holds. Worth noting for whoever picks this up: getTableConfig is dialect-specific and silently fails on a table from another dialect, so the test uses each engine's own. * generate the postgres and mysql schemas instead of hand-writing them The proof slice showed the constructs port, but left the maintenance question open. Three hand-written copies of 52 tables is the wrong answer: with foreign keys the copies cross-reference each other, so a renamed table has to land in three places consistently or a key silently points at the wrong one. The mapping is mechanical, so a script does it. schema.ts stays the single source of truth and schema.pg.ts / schema.mysql.ts are derived, covering all 52 tables — the column kit and the two-table portable slice are gone, since the generator now holds those decisions. The transforms are the ones the kit enumerated: integer-backed booleans become native, autoincrement keys become serial or int auto_increment, real becomes double precision or double, and any column that is a primary key, is unique, or sits on either end of a foreign key becomes varchar because MySQL cannot index unbounded TEXT. > termix@2.6.0 lint > node scripts/generate-dialect-schema.cjs --check && eslint . /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/database/routes/homepage-favicon-routes.ts 99:12 warning 'err' is defined but never used unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/database/routes/homepage-ping-routes.ts 123:12 warning 'err' is defined but never used unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/database/routes/homepage-rss-routes.ts 144:12 warning 'err' is defined but never used unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/database/routes/session-log-routes.ts 46:16 warning 'canAccessRecording' is defined but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/hosts/vault-signer-core.ts 55:12 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 75:13 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/tests/hosts/auth-manager.test.ts 18:73 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/tests/utils/shared-host-secrets-manager.test.ts 7:6 warning 'SecretRow' is defined but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/utils/auth-manager.ts 510:13 warning 'affectedUsers' is assigned a value but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/utils/notification-sender.ts 48:12 warning 'firstErr' is defined but never used unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/api/ssh-file-operations-api.ts 35:10 warning 'buildFileManagerUrl' is defined but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/components/folder-style.tsx 61:14 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components 116:14 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components 121:14 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components 149:17 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/components/proxmox/ProxmoxDiscoverDialog.tsx 109:19 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 190:19 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/HomepageCanvas.tsx 345:15 warning Empty block statement no-empty 388:15 warning Empty block statement no-empty 415:15 warning Empty block statement no-empty /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/dialogs/SingleHostEditForm.tsx 24:6 warning React Hook useEffect has a missing dependency: 'filter'. Either include it or remove the dependency array. If 'setHosts' needs the current value of 'filter', you can also switch to useReducer instead of useState and read 'filter' in the reducer react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/AlertFeedWidget.tsx 93:6 warning React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/CustomApiWidget.tsx 77:6 warning React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/DockerActivityWidget.tsx 50:6 warning React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/DockerWidget.tsx 16:10 warning Fast refresh only works when a file has exports. Move your component(s) to a separate file react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/FileManagerWidget.tsx 16:10 warning Fast refresh only works when a file has exports. Move your component(s) to a separate file react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/HostGridWidget.tsx 61:6 warning React Hook useCallback has a missing dependency: 'hostIds'. Either include it or remove the dependency array react-hooks/exhaustive-deps 61:7 warning React Hook useCallback has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/MetricsChartWidget.tsx 168:6 warning React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/PingStatusWidget.tsx 79:6 warning React Hook useEffect has a missing dependency: 'fetchAll'. Either include it or remove the dependency array react-hooks/exhaustive-deps 79:7 warning React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/QuickConnectWidget.tsx 64:10 warning Fast refresh only works when a file has exports. Move your component(s) to a separate file react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/RecentActivityWidget.tsx 82:6 warning React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array react-hooks/exhaustive-deps 82:17 warning React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/SshQuickConnectWidget.tsx 67:6 warning React Hook useCallback has a missing dependency: 'hostIds'. Either include it or remove the dependency array react-hooks/exhaustive-deps 67:7 warning React Hook useCallback has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked react-hooks/exhaustive-deps 99:17 warning 'online' is assigned a value but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/SshTerminalWidget.tsx 17:10 warning Fast refresh only works when a file has exports. Move your component(s) to a separate file react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/SystemOverviewWidget.tsx 72:6 warning React Hook useEffect has a missing dependency: 'fetchData'. Either include it or remove the dependency array react-hooks/exhaustive-deps /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/homepage/widgets/TunnelWidget.tsx 15:10 warning Fast refresh only works when a file has exports. Move your component(s) to a separate file react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/features/host-metrics/cards/CpuCard.tsx 14:10 warning 'computeChartData' is defined but never used. Allowed unused vars must match /^_/u unused-imports/no-unused-vars /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/sidebar/FolderPathPicker.tsx 15:17 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components 22:17 warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components react-refresh/only-export-components /mnt/c/Users/29037/WebstormProjects/Termix/src/ui/sidebar/HostsPanel.tsx 601:52 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any ✖ 44 problems (0 errors, 44 warnings) now fails if the generated files are out of date, so editing the schema without regenerating cannot reach main. * select durability behaviour per dialect, and document the backends The onWrite hook every repository receives exists to serialise the in-memory SQLite database back to its encrypted file. On a client-server engine a committed write is already durable and there is nothing to flush, so the factory now installs no hook at all rather than one that does nothing. Repositories call it as this.onWrite?.(), so none of the 43 of them change. Also adds docs/database-backends.md, mostly to be explicit about encryption, which is the part most likely to be misread. Field-level encryption is identical on all three engines and covers every credential. Whole-file encryption has no equivalent on Postgres or MySQL, so host names, snippet contents, audit entries and backups are only as protected as the storage underneath them — that is the operator's responsibility and the docs should not imply otherwise. * generate DDL with drizzle-kit, and give settings a synchronous path Two of the three remaining blockers. DDL: db/index.ts hand-writes 67 CREATE TABLE statements and 122 ADD COLUMN migrations, all in SQLite dialect. Rather than port them, drizzle-kit now generates migrations from the schema modules — 817 lines for Postgres, 869 for MySQL, with the type mapping already correct because the schemas it reads are themselves generated. > termix@2.6.0 schema:migrations > drizzle-kit generate --config=drizzle.config.pg.ts && drizzle-kit generate --config=drizzle.config.mysql.ts Reading config file '/mnt/c/Users/29037/WebstormProjects/Termix/drizzle.config.pg.ts' 52 tables alert_firings 11 columns 0 indexes 2 fks alert_rule_channels 3 columns 0 indexes 2 fks alert_rules 11 columns 0 indexes 2 fks api_keys 9 columns 0 indexes 1 fks audit_logs 13 columns 0 indexes 1 fks c2s_tunnel_presets 8 columns 0 indexes 1 fks command_history 5 columns 0 indexes 2 fks dashboard_service_links 8 columns 0 indexes 1 fks dismissed_alerts 4 columns 0 indexes 1 fks file_manager_pinned 6 columns 0 indexes 2 fks file_manager_recent 6 columns 0 indexes 2 fks file_manager_shortcuts 6 columns 0 indexes 2 fks homepage_items 9 columns 0 indexes 1 fks homepage_layouts 4 columns 0 indexes 1 fks host_access 11 columns 0 indexes 5 fks host_health_checks 7 columns 0 indexes 2 fks host_health_history 8 columns 0 indexes 2 fks host_metrics_history 8 columns 0 indexes 1 fks host_metrics_preferences 6 columns 0 indexes 2 fks ssh_data 94 columns 0 indexes 6 fks network_topology 5 columns 0 indexes 1 fks notification_channels 7 columns 0 indexes 1 fks opkssh_tokens 12 columns 0 indexes 2 fks recent_activity 6 columns 0 indexes 2 fks roles 8 columns 0 indexes 0 fks session_recordings 15 columns 0 indexes 3 fks session_share_participants 6 columns 0 indexes 2 fks session_shares 15 columns 0 indexes 3 fks sessions 11 columns 0 indexes 1 fks settings 2 columns 0 indexes 0 fks shared_host_secrets 15 columns 0 indexes 3 fks snippet_access 8 columns 0 indexes 4 fks snippet_folders 8 columns 0 indexes 1 fks snippets 11 columns 0 indexes 1 fks ssh_credential_usage 5 columns 0 indexes 3 fks ssh_credentials 21 columns 0 indexes 1 fks ssh_folders 9 columns 0 indexes 2 fks sso_providers 8 columns 0 indexes 0 fks sync_tombstones 5 columns 0 indexes 1 fks termix_identities 6 columns 0 indexes 1 fks termix_identity_ca 8 columns 0 indexes 2 fks termix_identity_keys 12 columns 0 indexes 3 fks tmux_session_tags 6 columns 0 indexes 2 fks transfer_recent 7 columns 0 indexes 3 fks trusted_devices 8 columns 0 indexes 1 fks user_open_tabs 9 columns 0 indexes 2 fks user_preferences 23 columns 0 indexes 1 fks user_roles 5 columns 0 indexes 3 fks users 20 columns 0 indexes 0 fks vault_profiles 18 columns 0 indexes 1 fks vault_tokens 8 columns 0 indexes 2 fks webauthn_credentials 12 columns 0 indexes 1 fks No schema changes, nothing to migrate 😴 Reading config file '/mnt/c/Users/29037/WebstormProjects/Termix/drizzle.config.mysql.ts' Reading schema files: /mnt/c/Users/29037/WebstormProjects/Termix/src/backend/database/db/schema.mysql.ts 52 tables alert_firings 11 columns 0 indexes 2 fks alert_rule_channels 3 columns 0 indexes 2 fks alert_rules 11 columns 0 indexes 2 fks api_keys 9 columns 0 indexes 1 fks audit_logs 13 columns 0 indexes 1 fks c2s_tunnel_presets 8 columns 0 indexes 1 fks command_history 5 columns 0 indexes 2 fks dashboard_service_links 8 columns 0 indexes 1 fks dismissed_alerts 4 columns 0 indexes 1 fks file_manager_pinned 6 columns 0 indexes 2 fks file_manager_recent 6 columns 0 indexes 2 fks file_manager_shortcuts 6 columns 0 indexes 2 fks homepage_items 9 columns 0 indexes 1 fks homepage_layouts 4 columns 0 indexes 1 fks host_access 11 columns 0 indexes 5 fks host_health_checks 7 columns 0 indexes 2 fks host_health_history 8 columns 0 indexes 2 fks host_metrics_history 8 columns 0 indexes 1 fks host_metrics_preferences 6 columns 0 indexes 2 fks ssh_data 94 columns 0 indexes 6 fks network_topology 5 columns 0 indexes 1 fks notification_channels 7 columns 0 indexes 1 fks opkssh_tokens 12 columns 0 indexes 2 fks recent_activity 6 columns 0 indexes 2 fks roles 8 columns 0 indexes 0 fks session_recordings 15 columns 0 indexes 3 fks session_share_participants 6 columns 0 indexes 2 fks session_shares 15 columns 0 indexes 3 fks sessions 11 columns 0 indexes 1 fks settings 2 columns 0 indexes 0 fks shared_host_secrets 15 columns 0 indexes 3 fks snippet_access 8 columns 0 indexes 4 fks snippet_folders 8 columns 0 indexes 1 fks snippets 11 columns 0 indexes 1 fks ssh_credential_usage 5 columns 0 indexes 3 fks ssh_credentials 21 columns 0 indexes 1 fks ssh_folders 9 columns 0 indexes 2 fks sso_providers 8 columns 0 indexes 0 fks sync_tombstones 5 columns 0 indexes 1 fks termix_identities 6 columns 0 indexes 1 fks termix_identity_ca 8 columns 0 indexes 2 fks termix_identity_keys 12 columns 0 indexes 3 fks tmux_session_tags 6 columns 0 indexes 2 fks transfer_recent 7 columns 0 indexes 3 fks trusted_devices 8 columns 0 indexes 1 fks user_open_tabs 9 columns 0 indexes 2 fks user_preferences 23 columns 0 indexes 1 fks user_roles 5 columns 0 indexes 3 fks users 20 columns 0 indexes 0 fks vault_profiles 18 columns 0 indexes 1 fks vault_tokens 8 columns 0 indexes 2 fks webauthn_credentials 12 columns 0 indexes 1 fks No schema changes, nothing to migrate 😴 regenerates both. Settings: 27 call sites read settings synchronously, during startup and inside request handlers. better-sqlite3 can do that; Postgres and MySQL cannot, and making all 27 async would push await through code that has no reason to be asynchronous. Settings are a handful of rarely-changing rows read constantly, so they are cached in full — primed at startup, kept in step by SettingsRepository on every set/delete/deleteLike. SQLite keeps reading the database directly and stays authoritative; only the other engines use the cache. Opening a connection is still not done. DatabaseContext.drizzle is typed as BetterSQLite3Database and 43 repositories depend on that inference; the three drizzle instance types are not interchangeable, so widening it is a design decision rather than a mechanical change. * exclude drizzle-kit output from prettier The generated migrations and snapshots are tool output; their formatting is drizzle-kit's to decide, and prettier cannot parse the .sql files at all. * absorb the RETURNING gap so mysql stays reachable MySQL has no RETURNING clause and drizzle's mysql-core does not expose the method, while 156 call sites here read the result of a write. That is the real blocker for MySQL, not the connection layer. Classifying those call sites showed the split is favourable: 92 of them only read .length, which every engine reports — as a returned array on sqlite and postgres, as affectedRows on MySQL. rowsAffected() reads both shapes, so those sites need no change in query shape. insertedId() does the same for the autoincrement key, which MySQL reports as insertId. What is left is the ~34 sites that genuinely consume the returned rows. Those cannot be emulated without reading first, which needs a transaction to stay correct under concurrency, so they will be handled individually rather than behind a helper that quietly adds a round trip. supportsReturning() is the seam for that. Identifying the mysql2 result by its own fields rather than by array shape matters: it hands back [ResultSetHeader, fields], which is an array, so shape alone cannot tell it apart from a returning() result. * name the portable database type, and open remote connections Two pieces of the connection layer. drizzle's three Database classes share no base class and their signatures are incompatible, so there is no honest type that covers all three: a union is not callable and a generic would have to be threaded through 43 repositories and every method on them. DatabaseContext.drizzle is now PortableDatabase, still the SQLite type underneath, but named and documented as the deliberate approximation it is. What makes it safe is that the equivalence is asserted in multi-dialect.test.ts rather than assumed, and the one place the surfaces truly differ — RETURNING — is handled explicitly in mutation-result.ts. connect.ts opens Postgres and MySQL from DATABASE_URL, with the schema module and driver imported lazily so neither is loaded on a SQLite deployment. The URL scheme is checked against the configured dialect first: a postgres:// URL with DATABASE_DIALECT=mysql otherwise surfaces as a driver error deep in a stack that never mentions the actual misconfiguration. * open postgres and mysql at startup * count writes without RETURNING * read affected rows without RETURNING on mysql * insert without RETURNING, and split the sync transactions * stop pretending the generated schemas are used at runtime * run the dialect checks in CI * mysql rejects a bare CURRENT_TIMESTAMP default on text * make the read-back mismatch loud, and stop the next bare returning() * run the repository tests on the real schema * skip the byte-level assertions off sqlite * move generated ids past the seeded ones * keep the export order the same on every engine * stop reading better-sqlite3 fields off every write * read counts as numbers, not whatever the driver returns * make the fixture usable against a live server * upsert on the engine that has no ON CONFLICT * run the repository suite on all three engines in CI * mysql cannot index a text column without a length * document how to actually run on postgres or mysql * keep the sqlite-era migrations off the other engines * concat strings in a way mysql agrees with * run every repository test on every engine * bound how long replicas can disagree about settings * generate the sqlite migrations alongside the others
876 lines
43 KiB
SQL
876 lines
43 KiB
SQL
CREATE TABLE `alert_firings` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`rule_id` int NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`host_name` text NOT NULL,
|
|
`fired_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`resolved_at` text,
|
|
`value` double,
|
|
`message` text NOT NULL,
|
|
`severity` text NOT NULL DEFAULT ('warning'),
|
|
`acknowledged` boolean NOT NULL DEFAULT false,
|
|
CONSTRAINT `alert_firings_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `alert_rule_channels` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`rule_id` int NOT NULL,
|
|
`channel_id` int NOT NULL,
|
|
CONSTRAINT `alert_rule_channels_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `alert_rules` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int,
|
|
`name` varchar(255) NOT NULL,
|
|
`enabled` boolean NOT NULL DEFAULT true,
|
|
`trigger_type` text NOT NULL,
|
|
`threshold_value` double,
|
|
`threshold_duration_seconds` int,
|
|
`cooldown_minutes` int NOT NULL DEFAULT 15,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `alert_rules_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `api_keys` (
|
|
`id` varchar(255) NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`token_hash` text NOT NULL,
|
|
`token_prefix` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`expires_at` text,
|
|
`last_used_at` text,
|
|
`is_active` boolean NOT NULL DEFAULT true,
|
|
CONSTRAINT `api_keys_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `audit_logs` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255),
|
|
`username` text NOT NULL,
|
|
`action` text NOT NULL,
|
|
`resource_type` text NOT NULL,
|
|
`resource_id` text,
|
|
`resource_name` text,
|
|
`details` text,
|
|
`ip_address` text,
|
|
`user_agent` text,
|
|
`success` boolean NOT NULL,
|
|
`error_message` text,
|
|
`timestamp` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `audit_logs_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `c2s_tunnel_presets` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`config` text NOT NULL,
|
|
`platform` text,
|
|
`computer_name` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `c2s_tunnel_presets_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `command_history` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`command` text NOT NULL,
|
|
`executed_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `command_history_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `dashboard_service_links` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`label` text NOT NULL,
|
|
`url` text NOT NULL,
|
|
`order` int NOT NULL DEFAULT 0,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `dashboard_service_links_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `dashboard_service_links_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `dismissed_alerts` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`alert_id` text NOT NULL,
|
|
`dismissed_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `dismissed_alerts_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `file_manager_pinned` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`path` text NOT NULL,
|
|
`pinned_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `file_manager_pinned_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `file_manager_recent` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`path` text NOT NULL,
|
|
`last_opened` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `file_manager_recent_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `file_manager_shortcuts` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`path` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `file_manager_shortcuts_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `homepage_items` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`type_id` text NOT NULL,
|
|
`title` text,
|
|
`config` text NOT NULL DEFAULT ('{}'),
|
|
`folder_id` int,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `homepage_items_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `homepage_items_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `homepage_layouts` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`layout` text NOT NULL DEFAULT ('{}'),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `homepage_layouts_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `homepage_layouts_user_id_unique` UNIQUE(`user_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `host_access` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`user_id` varchar(255),
|
|
`role_id` int,
|
|
`granted_by` varchar(255) NOT NULL,
|
|
`permission_level` text NOT NULL DEFAULT ('connect'),
|
|
`expires_at` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`last_accessed_at` text,
|
|
`access_count` int NOT NULL DEFAULT 0,
|
|
`override_credential_id` int,
|
|
CONSTRAINT `host_access_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `host_health_checks` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`checks` text NOT NULL,
|
|
`interval_seconds` int NOT NULL DEFAULT 300,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `host_health_checks_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `idx_host_health_checks_user_host` UNIQUE(`user_id`,`host_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `host_health_history` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`check_id` text NOT NULL,
|
|
`ts` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`ok` boolean NOT NULL,
|
|
`latency_ms` int,
|
|
`detail` text,
|
|
CONSTRAINT `host_health_history_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `host_metrics_history` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`ts` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`cpu_percent` double,
|
|
`mem_percent` double,
|
|
`disk_percent` double,
|
|
`net_rx_bytes` int,
|
|
`net_tx_bytes` int,
|
|
CONSTRAINT `host_metrics_history_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `host_metrics_preferences` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`layout` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `host_metrics_preferences_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `idx_host_metrics_prefs_user_host` UNIQUE(`user_id`,`host_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `ssh_data` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`connection_type` text NOT NULL DEFAULT ('ssh'),
|
|
`name` varchar(255),
|
|
`ip` text NOT NULL,
|
|
`port` int NOT NULL,
|
|
`username` text NOT NULL,
|
|
`folder` text,
|
|
`tags` text,
|
|
`pin` boolean NOT NULL DEFAULT false,
|
|
`auth_type` text NOT NULL,
|
|
`use_warpgate` boolean NOT NULL DEFAULT false,
|
|
`force_keyboard_interactive` text,
|
|
`password` text,
|
|
`key` text,
|
|
`key_password` text,
|
|
`key_type` text,
|
|
`sudo_password` text,
|
|
`autostart_password` text,
|
|
`autostart_key` text,
|
|
`autostart_key_password` text,
|
|
`credential_id` int,
|
|
`override_credential_username` boolean,
|
|
`vault_profile_id` int,
|
|
`enable_terminal` boolean NOT NULL DEFAULT true,
|
|
`enable_session_logging` boolean NOT NULL DEFAULT true,
|
|
`allow_session_sharing` boolean NOT NULL DEFAULT true,
|
|
`enable_command_history` boolean NOT NULL DEFAULT true,
|
|
`enable_tunnel` boolean NOT NULL DEFAULT true,
|
|
`tunnel_connections` text,
|
|
`jump_hosts` text,
|
|
`enable_file_manager` boolean NOT NULL DEFAULT true,
|
|
`scp_legacy` boolean NOT NULL DEFAULT false,
|
|
`enable_docker` boolean NOT NULL DEFAULT false,
|
|
`enable_tmux_monitor` boolean NOT NULL DEFAULT false,
|
|
`show_terminal_in_sidebar` boolean NOT NULL DEFAULT true,
|
|
`show_file_manager_in_sidebar` boolean NOT NULL DEFAULT false,
|
|
`show_tunnel_in_sidebar` boolean NOT NULL DEFAULT false,
|
|
`show_docker_in_sidebar` boolean NOT NULL DEFAULT false,
|
|
`show_server_stats_in_sidebar` boolean NOT NULL DEFAULT false,
|
|
`default_path` text,
|
|
`stats_config` text,
|
|
`docker_config` text,
|
|
`enable_proxmox` boolean NOT NULL DEFAULT false,
|
|
`proxmox_config` text,
|
|
`terminal_config` text,
|
|
`quick_actions` text,
|
|
`notes` text,
|
|
`enable_ssh` boolean NOT NULL DEFAULT true,
|
|
`enable_rdp` boolean NOT NULL DEFAULT false,
|
|
`enable_vnc` boolean NOT NULL DEFAULT false,
|
|
`enable_telnet` boolean NOT NULL DEFAULT false,
|
|
`ssh_port` int DEFAULT 22,
|
|
`rdp_port` int DEFAULT 3389,
|
|
`vnc_port` int DEFAULT 5900,
|
|
`telnet_port` int DEFAULT 23,
|
|
`rdp_credential_id` int,
|
|
`rdp_user` text,
|
|
`rdp_password` text,
|
|
`rdp_domain` text,
|
|
`rdp_security` text,
|
|
`rdp_ignore_cert` boolean DEFAULT false,
|
|
`vnc_credential_id` int,
|
|
`vnc_password` text,
|
|
`vnc_user` text,
|
|
`telnet_user` text,
|
|
`telnet_password` text,
|
|
`telnet_credential_id` int,
|
|
`rdp_auth_type` text,
|
|
`vnc_auth_type` text,
|
|
`telnet_auth_type` text,
|
|
`domain` text,
|
|
`security` text,
|
|
`ignore_cert` boolean DEFAULT false,
|
|
`guacamole_config` text,
|
|
`use_socks5` boolean,
|
|
`socks5_host` text,
|
|
`socks5_port` int,
|
|
`socks5_username` text,
|
|
`socks5_password` text,
|
|
`socks5_proxy_chain` text,
|
|
`connection_origin` text,
|
|
`mac_address` text,
|
|
`wol_broadcast_address` text,
|
|
`port_knock_sequence` text,
|
|
`host_key_fingerprint` text,
|
|
`host_key_type` text,
|
|
`host_key_algorithm` text DEFAULT ('sha256'),
|
|
`host_key_first_seen` text,
|
|
`host_key_last_verified` text,
|
|
`host_key_changed_count` int DEFAULT 0,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `ssh_data_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `ssh_data_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `network_topology` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`topology` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `network_topology_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `notification_channels` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`type` text NOT NULL,
|
|
`config` text NOT NULL,
|
|
`enabled` boolean NOT NULL DEFAULT true,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `notification_channels_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `opkssh_tokens` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`ssh_cert` text NOT NULL,
|
|
`private_key` text NOT NULL,
|
|
`email` text,
|
|
`sub` text,
|
|
`issuer` text,
|
|
`audience` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`expires_at` text NOT NULL,
|
|
`last_used` text,
|
|
CONSTRAINT `opkssh_tokens_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `idx_opkssh_tokens_user_host` UNIQUE(`user_id`,`host_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `recent_activity` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`type` text NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`host_name` text,
|
|
`timestamp` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `recent_activity_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `roles` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`display_name` text NOT NULL,
|
|
`description` text,
|
|
`is_system` boolean NOT NULL DEFAULT false,
|
|
`permissions` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `roles_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `roles_name_unique` UNIQUE(`name`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `session_recordings` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`user_id` varchar(255),
|
|
`username` text,
|
|
`access_id` int,
|
|
`started_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`ended_at` text,
|
|
`duration` int,
|
|
`commands` text,
|
|
`dangerous_actions` text,
|
|
`recording_path` text,
|
|
`protocol` varchar(255) NOT NULL DEFAULT 'ssh',
|
|
`format` text NOT NULL DEFAULT ('text'),
|
|
`terminated_by_owner` boolean DEFAULT false,
|
|
`termination_reason` text,
|
|
CONSTRAINT `session_recordings_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `session_share_participants` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`share_id` varchar(255) NOT NULL,
|
|
`user_id` varchar(255),
|
|
`guest_label` text,
|
|
`joined_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`left_at` text,
|
|
CONSTRAINT `session_share_participants_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `session_shares` (
|
|
`id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`owner_user_id` varchar(255) NOT NULL,
|
|
`protocol` varchar(255) NOT NULL,
|
|
`session_id` text NOT NULL,
|
|
`tab_instance_id` text,
|
|
`share_type` text NOT NULL,
|
|
`target_user_id` varchar(255),
|
|
`link_token` varchar(255),
|
|
`permission_level` text NOT NULL DEFAULT ('read-only'),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`expires_at` text NOT NULL,
|
|
`revoked_at` text,
|
|
`last_joined_at` text,
|
|
`join_count` int NOT NULL DEFAULT 0,
|
|
CONSTRAINT `session_shares_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `session_shares_link_token_unique` UNIQUE(`link_token`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `sessions` (
|
|
`id` varchar(255) NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`jwt_token` text NOT NULL,
|
|
`device_type` text NOT NULL,
|
|
`device_info` text NOT NULL,
|
|
`oidc_sub` text,
|
|
`oidc_sid` text,
|
|
`sso_provider_id` int,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`expires_at` text NOT NULL,
|
|
`last_active_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `sessions_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `settings` (
|
|
`key` varchar(255) NOT NULL,
|
|
`value` text NOT NULL,
|
|
CONSTRAINT `settings_key` PRIMARY KEY(`key`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `shared_host_secrets` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`host_access_id` int NOT NULL,
|
|
`target_user_id` varchar(255) NOT NULL,
|
|
`protocol` varchar(255) NOT NULL DEFAULT 'ssh',
|
|
`source_type` text NOT NULL DEFAULT ('credential'),
|
|
`original_credential_id` int,
|
|
`encrypted_username` text,
|
|
`encrypted_auth_type` text,
|
|
`encrypted_password` text,
|
|
`encrypted_key` text,
|
|
`encrypted_key_password` text,
|
|
`encrypted_key_type` text,
|
|
`encrypted_domain` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `shared_host_secrets_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `idx_shared_host_secrets_scope` UNIQUE(`host_access_id`,`target_user_id`,`protocol`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `snippet_access` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`snippet_id` int NOT NULL,
|
|
`user_id` varchar(255),
|
|
`role_id` int,
|
|
`granted_by` varchar(255) NOT NULL,
|
|
`permission_level` text NOT NULL DEFAULT ('view'),
|
|
`expires_at` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `snippet_access_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `snippet_folders` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`color` text,
|
|
`icon` text,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `snippet_folders_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `snippet_folders_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `snippets` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`content` text NOT NULL,
|
|
`description` text,
|
|
`folder` text,
|
|
`order` int NOT NULL DEFAULT 0,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`host_filter` text,
|
|
CONSTRAINT `snippets_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `snippets_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `ssh_credential_usage` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`credential_id` int NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`used_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `ssh_credential_usage_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `ssh_credentials` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`description` text,
|
|
`folder` text,
|
|
`tags` text,
|
|
`auth_type` text NOT NULL,
|
|
`username` text,
|
|
`password` text,
|
|
`key` text,
|
|
`private_key` text,
|
|
`public_key` text,
|
|
`key_password` text,
|
|
`key_type` text,
|
|
`detected_key_type` text,
|
|
`cert_public_key` text,
|
|
`usage_count` int NOT NULL DEFAULT 0,
|
|
`last_used` text,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `ssh_credentials_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `ssh_credentials_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `ssh_folders` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`color` text,
|
|
`icon` text,
|
|
`credential_id` int,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `ssh_folders_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `ssh_folders_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `sso_providers` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`type` text NOT NULL,
|
|
`enabled` boolean NOT NULL DEFAULT true,
|
|
`display_order` int NOT NULL DEFAULT 0,
|
|
`config` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `sso_providers_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `sync_tombstones` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`entity_type` text NOT NULL,
|
|
`sync_id` varchar(255) NOT NULL,
|
|
`deleted_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `sync_tombstones_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `termix_identities` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`handle` varchar(255) NOT NULL,
|
|
`description` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `termix_identities_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `termix_identities_user_id_unique` UNIQUE(`user_id`),
|
|
CONSTRAINT `termix_identities_handle_unique` UNIQUE(`handle`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `termix_identity_ca` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`identity_id` int NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`public_key` text NOT NULL,
|
|
`private_key` text NOT NULL,
|
|
`validity_days` int NOT NULL DEFAULT 90,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `termix_identity_ca_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `termix_identity_ca_identity_id_unique` UNIQUE(`identity_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `termix_identity_keys` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`identity_id` int NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`public_key` text NOT NULL,
|
|
`key_type` text NOT NULL,
|
|
`algorithm` text NOT NULL,
|
|
`label` text,
|
|
`comment` text,
|
|
`source` text NOT NULL DEFAULT ('manual'),
|
|
`credential_id` int,
|
|
`enabled` boolean NOT NULL DEFAULT true,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `termix_identity_keys_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `tmux_session_tags` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`session_name` text NOT NULL,
|
|
`tag` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `tmux_session_tags_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `transfer_recent` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`source_host_id` int NOT NULL,
|
|
`dest_host_id` int NOT NULL,
|
|
`dest_path` text NOT NULL,
|
|
`dest_path_label` text NOT NULL,
|
|
`last_used` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `transfer_recent_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `trusted_devices` (
|
|
`id` varchar(255) NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`device_fingerprint` text NOT NULL,
|
|
`device_type` text NOT NULL,
|
|
`device_info` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`expires_at` text NOT NULL,
|
|
`last_used_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `trusted_devices_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `user_open_tabs` (
|
|
`id` varchar(255) NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`tab_type` text NOT NULL,
|
|
`host_id` int,
|
|
`label` text NOT NULL,
|
|
`tab_order` int NOT NULL DEFAULT 0,
|
|
`backend_session_id` text,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `user_open_tabs_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `user_preferences` (
|
|
`user_id` varchar(255) NOT NULL,
|
|
`reopen_tabs_on_login` boolean NOT NULL DEFAULT false,
|
|
`theme` text,
|
|
`font_size` text,
|
|
`accent_color` text,
|
|
`language` text,
|
|
`storage_mode` text,
|
|
`command_autocomplete` boolean,
|
|
`command_palette_enabled` boolean,
|
|
`show_host_tags` boolean,
|
|
`host_tray_on_click` boolean,
|
|
`pin_app_rail` boolean,
|
|
`expand_app_rail_on_hover` boolean,
|
|
`folders_collapsed` boolean,
|
|
`confirm_snippet_execution` boolean,
|
|
`disable_update_check` boolean,
|
|
`confirm_tab_close` boolean,
|
|
`hidden_rail_tabs` text,
|
|
`compact_host_view` boolean,
|
|
`status_color_scheme` text,
|
|
`custom_themes` text,
|
|
`custom_keybindings` text,
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `user_preferences_user_id` PRIMARY KEY(`user_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `user_roles` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`role_id` int NOT NULL,
|
|
`granted_by` varchar(255),
|
|
`granted_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `user_roles_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `idx_user_roles_user_role` UNIQUE(`user_id`,`role_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `users` (
|
|
`id` varchar(255) NOT NULL,
|
|
`username` text NOT NULL,
|
|
`password_hash` text NOT NULL,
|
|
`is_admin` boolean NOT NULL DEFAULT false,
|
|
`is_oidc` boolean NOT NULL DEFAULT false,
|
|
`oidc_identifier` text,
|
|
`sso_provider_id` int,
|
|
`client_id` text,
|
|
`client_secret` text,
|
|
`issuer_url` text,
|
|
`authorization_url` text,
|
|
`token_url` text,
|
|
`identifier_path` text,
|
|
`name_path` text,
|
|
`scopes` text DEFAULT ('openid email profile'),
|
|
`totp_secret` text,
|
|
`totp_enabled` boolean NOT NULL DEFAULT false,
|
|
`totp_backup_codes` text,
|
|
`registered_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`donation_modal_dismissed` boolean NOT NULL DEFAULT false,
|
|
CONSTRAINT `users_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `vault_profiles` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`description` text,
|
|
`folder` text,
|
|
`tags` text,
|
|
`vault_addr` text NOT NULL,
|
|
`vault_namespace` text,
|
|
`oidc_mount` text,
|
|
`oidc_role` text,
|
|
`ssh_mount` text,
|
|
`ssh_role` text NOT NULL,
|
|
`valid_principals` text,
|
|
`key_type` text,
|
|
`shared` boolean NOT NULL DEFAULT false,
|
|
`sync_id` varchar(255),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
CONSTRAINT `vault_profiles_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `vault_profiles_sync_id_unique` UNIQUE(`sync_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `vault_tokens` (
|
|
`id` int AUTO_INCREMENT NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`profile_id` int NOT NULL,
|
|
`ssh_cert` text NOT NULL,
|
|
`private_key` text NOT NULL,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`expires_at` text NOT NULL,
|
|
`last_used` text,
|
|
CONSTRAINT `vault_tokens_id` PRIMARY KEY(`id`),
|
|
CONSTRAINT `idx_vault_tokens_user_profile` UNIQUE(`user_id`,`profile_id`)
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `webauthn_credentials` (
|
|
`id` varchar(255) NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`credential_id` text NOT NULL,
|
|
`public_key` text NOT NULL,
|
|
`counter` int NOT NULL DEFAULT 0,
|
|
`device_type` text,
|
|
`backed_up` boolean NOT NULL DEFAULT false,
|
|
`transports` text,
|
|
`user_verification` text NOT NULL DEFAULT ('preferred'),
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`last_used_at` text,
|
|
CONSTRAINT `webauthn_credentials_id` PRIMARY KEY(`id`)
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE `alert_firings` ADD CONSTRAINT `alert_firings_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `alert_firings` ADD CONSTRAINT `alert_firings_rule_id_alert_rules_id_fk` FOREIGN KEY (`rule_id`) REFERENCES `alert_rules`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `alert_rule_channels` ADD CONSTRAINT `alert_rule_channels_rule_id_alert_rules_id_fk` FOREIGN KEY (`rule_id`) REFERENCES `alert_rules`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `alert_rule_channels` ADD CONSTRAINT `alert_rule_channels_channel_id_notification_channels_id_fk` FOREIGN KEY (`channel_id`) REFERENCES `notification_channels`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `alert_rules` ADD CONSTRAINT `alert_rules_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `alert_rules` ADD CONSTRAINT `alert_rules_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `api_keys` ADD CONSTRAINT `api_keys_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `audit_logs` ADD CONSTRAINT `audit_logs_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `c2s_tunnel_presets` ADD CONSTRAINT `c2s_tunnel_presets_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `command_history` ADD CONSTRAINT `command_history_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `command_history` ADD CONSTRAINT `command_history_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `dashboard_service_links` ADD CONSTRAINT `dashboard_service_links_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `dismissed_alerts` ADD CONSTRAINT `dismissed_alerts_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `file_manager_pinned` ADD CONSTRAINT `file_manager_pinned_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `file_manager_pinned` ADD CONSTRAINT `file_manager_pinned_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `file_manager_recent` ADD CONSTRAINT `file_manager_recent_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `file_manager_recent` ADD CONSTRAINT `file_manager_recent_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `file_manager_shortcuts` ADD CONSTRAINT `file_manager_shortcuts_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `file_manager_shortcuts` ADD CONSTRAINT `file_manager_shortcuts_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `homepage_items` ADD CONSTRAINT `homepage_items_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `homepage_layouts` ADD CONSTRAINT `homepage_layouts_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_access` ADD CONSTRAINT `host_access_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_access` ADD CONSTRAINT `host_access_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_access` ADD CONSTRAINT `host_access_role_id_roles_id_fk` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_access` ADD CONSTRAINT `host_access_granted_by_users_id_fk` FOREIGN KEY (`granted_by`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_access` ADD CONSTRAINT `host_access_override_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`override_credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_health_checks` ADD CONSTRAINT `host_health_checks_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_health_checks` ADD CONSTRAINT `host_health_checks_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_health_history` ADD CONSTRAINT `host_health_history_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_health_history` ADD CONSTRAINT `host_health_history_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_metrics_history` ADD CONSTRAINT `host_metrics_history_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_metrics_preferences` ADD CONSTRAINT `host_metrics_preferences_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `host_metrics_preferences` ADD CONSTRAINT `host_metrics_preferences_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_data` ADD CONSTRAINT `ssh_data_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_data` ADD CONSTRAINT `ssh_data_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_data` ADD CONSTRAINT `ssh_data_vault_profile_id_vault_profiles_id_fk` FOREIGN KEY (`vault_profile_id`) REFERENCES `vault_profiles`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_data` ADD CONSTRAINT `ssh_data_rdp_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`rdp_credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_data` ADD CONSTRAINT `ssh_data_vnc_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`vnc_credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_data` ADD CONSTRAINT `ssh_data_telnet_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`telnet_credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `network_topology` ADD CONSTRAINT `network_topology_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `notification_channels` ADD CONSTRAINT `notification_channels_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `opkssh_tokens` ADD CONSTRAINT `opkssh_tokens_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `opkssh_tokens` ADD CONSTRAINT `opkssh_tokens_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `recent_activity` ADD CONSTRAINT `recent_activity_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `recent_activity` ADD CONSTRAINT `recent_activity_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_recordings` ADD CONSTRAINT `session_recordings_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_recordings` ADD CONSTRAINT `session_recordings_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_recordings` ADD CONSTRAINT `session_recordings_access_id_host_access_id_fk` FOREIGN KEY (`access_id`) REFERENCES `host_access`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_share_participants` ADD CONSTRAINT `session_share_participants_share_id_session_shares_id_fk` FOREIGN KEY (`share_id`) REFERENCES `session_shares`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_share_participants` ADD CONSTRAINT `session_share_participants_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_shares` ADD CONSTRAINT `session_shares_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_shares` ADD CONSTRAINT `session_shares_owner_user_id_users_id_fk` FOREIGN KEY (`owner_user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `session_shares` ADD CONSTRAINT `session_shares_target_user_id_users_id_fk` FOREIGN KEY (`target_user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `shared_host_secrets` ADD CONSTRAINT `shared_host_secrets_host_access_id_host_access_id_fk` FOREIGN KEY (`host_access_id`) REFERENCES `host_access`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `shared_host_secrets` ADD CONSTRAINT `shared_host_secrets_target_user_id_users_id_fk` FOREIGN KEY (`target_user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `shared_host_secrets` ADD CONSTRAINT `shared_host_secrets_original_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`original_credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `snippet_access` ADD CONSTRAINT `snippet_access_snippet_id_snippets_id_fk` FOREIGN KEY (`snippet_id`) REFERENCES `snippets`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `snippet_access` ADD CONSTRAINT `snippet_access_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `snippet_access` ADD CONSTRAINT `snippet_access_role_id_roles_id_fk` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `snippet_access` ADD CONSTRAINT `snippet_access_granted_by_users_id_fk` FOREIGN KEY (`granted_by`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `snippet_folders` ADD CONSTRAINT `snippet_folders_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `snippets` ADD CONSTRAINT `snippets_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_credential_usage` ADD CONSTRAINT `ssh_credential_usage_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_credential_usage` ADD CONSTRAINT `ssh_credential_usage_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_credential_usage` ADD CONSTRAINT `ssh_credential_usage_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_credentials` ADD CONSTRAINT `ssh_credentials_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_folders` ADD CONSTRAINT `ssh_folders_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `ssh_folders` ADD CONSTRAINT `ssh_folders_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `sync_tombstones` ADD CONSTRAINT `sync_tombstones_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `termix_identities` ADD CONSTRAINT `termix_identities_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `termix_identity_ca` ADD CONSTRAINT `termix_identity_ca_identity_id_termix_identities_id_fk` FOREIGN KEY (`identity_id`) REFERENCES `termix_identities`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `termix_identity_ca` ADD CONSTRAINT `termix_identity_ca_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `termix_identity_keys` ADD CONSTRAINT `termix_identity_keys_identity_id_termix_identities_id_fk` FOREIGN KEY (`identity_id`) REFERENCES `termix_identities`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `termix_identity_keys` ADD CONSTRAINT `termix_identity_keys_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `termix_identity_keys` ADD CONSTRAINT `termix_identity_keys_credential_id_ssh_credentials_id_fk` FOREIGN KEY (`credential_id`) REFERENCES `ssh_credentials`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `tmux_session_tags` ADD CONSTRAINT `tmux_session_tags_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `tmux_session_tags` ADD CONSTRAINT `tmux_session_tags_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `transfer_recent` ADD CONSTRAINT `transfer_recent_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `transfer_recent` ADD CONSTRAINT `transfer_recent_source_host_id_ssh_data_id_fk` FOREIGN KEY (`source_host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `transfer_recent` ADD CONSTRAINT `transfer_recent_dest_host_id_ssh_data_id_fk` FOREIGN KEY (`dest_host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `trusted_devices` ADD CONSTRAINT `trusted_devices_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `user_open_tabs` ADD CONSTRAINT `user_open_tabs_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `user_open_tabs` ADD CONSTRAINT `user_open_tabs_host_id_ssh_data_id_fk` FOREIGN KEY (`host_id`) REFERENCES `ssh_data`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `user_preferences` ADD CONSTRAINT `user_preferences_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `user_roles` ADD CONSTRAINT `user_roles_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `user_roles` ADD CONSTRAINT `user_roles_role_id_roles_id_fk` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `user_roles` ADD CONSTRAINT `user_roles_granted_by_users_id_fk` FOREIGN KEY (`granted_by`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `vault_profiles` ADD CONSTRAINT `vault_profiles_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `vault_tokens` ADD CONSTRAINT `vault_tokens_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `vault_tokens` ADD CONSTRAINT `vault_tokens_profile_id_vault_profiles_id_fk` FOREIGN KEY (`profile_id`) REFERENCES `vault_profiles`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE `webauthn_credentials` ADD CONSTRAINT `webauthn_credentials_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action; |