-- Termix 2.8.0 to 2.9.0 on postgres, generated by scripts/lib/upgrade-sql.mjs -- ==== core 0025_purple_squirrel_girl ==== CREATE TABLE "plugin_storage" ( "id" serial PRIMARY KEY NOT NULL, "plugin_id" varchar(255) NOT NULL, "key" varchar(255) NOT NULL, "value" text NOT NULL, "updated_at" varchar(255) DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "plugin_storage" ADD CONSTRAINT "plugin_storage_plugin_id_plugins_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."plugins"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "idx_plugin_storage_plugin_key" ON "plugin_storage" USING btree ("plugin_id","key"); -- ==== core 0026_perfect_masque ==== DROP TABLE "alert_firings" CASCADE;--> statement-breakpoint DROP TABLE "alert_rule_channels" CASCADE;--> statement-breakpoint DROP TABLE "alert_rules" CASCADE; -- ==== core 0027_sharp_guardian ==== ALTER TABLE "plugin_permission_grants" ALTER COLUMN "granted_by" DROP NOT NULL;--> statement-breakpoint ALTER TABLE "plugin_permission_grants" ADD COLUMN "source" text DEFAULT 'admin' NOT NULL;--> statement-breakpoint ALTER TABLE "plugins" ADD COLUMN "last_error" text; -- ==== core 0028_whole_zemo ==== CREATE TABLE "plugin_migrations" ( "id" serial PRIMARY KEY NOT NULL, "plugin_id" varchar(255) NOT NULL, "migration_id" varchar(255) NOT NULL, "checksum" text NOT NULL, "applied_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "plugin_migrations" ADD CONSTRAINT "plugin_migrations_plugin_id_plugins_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."plugins"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "idx_plugin_migrations_plugin_migration" ON "plugin_migrations" USING btree ("plugin_id","migration_id"); -- ==== core 0029_nosy_roulette ==== CREATE TABLE "rbac_applied_defaults" ( "id" serial PRIMARY KEY NOT NULL, "role_name" varchar(255) NOT NULL, "permission" varchar(255) NOT NULL, "applied_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint CREATE TABLE "rbac_known_permissions" ( "id" serial PRIMARY KEY NOT NULL, "permission" varchar(255) NOT NULL, "plugin_id" varchar(255), "first_seen_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX "idx_rbac_applied_defaults_role_permission" ON "rbac_applied_defaults" USING btree ("role_name","permission");--> statement-breakpoint CREATE UNIQUE INDEX "idx_rbac_known_permissions_permission" ON "rbac_known_permissions" USING btree ("permission"); -- ==== core 0030_cynical_callisto ==== CREATE TABLE "plugin_settings" ( "id" serial PRIMARY KEY NOT NULL, "plugin_id" varchar(255) NOT NULL, "scope" varchar(255) NOT NULL, "scope_id" varchar(255), "key" varchar(255) NOT NULL, "value" text, "encrypted" boolean DEFAULT false NOT NULL, "updated_at" varchar(255) DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "plugin_settings" ADD CONSTRAINT "plugin_settings_plugin_id_plugins_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."plugins"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "idx_plugin_settings_scope_key" ON "plugin_settings" USING btree ("plugin_id","scope","scope_id","key");--> statement-breakpoint CREATE INDEX "idx_plugin_settings_plugin_scope" ON "plugin_settings" USING btree ("plugin_id","scope"); -- ==== core 0031_nifty_sentry ==== CREATE TABLE "user_external_identities" ( "id" serial PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "provider_id" varchar(255) NOT NULL, "subject" varchar(255) NOT NULL, "email" text, "created_at" varchar(255) DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint CREATE TABLE "user_second_factors" ( "id" serial PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "plugin_id" varchar(255) NOT NULL, "factor_id" varchar(255) NOT NULL, "enrolled_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "user_external_identities" ADD CONSTRAINT "user_external_identities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "user_second_factors" ADD CONSTRAINT "user_second_factors_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "idx_user_external_identities_provider_subject" ON "user_external_identities" USING btree ("provider_id","subject");--> statement-breakpoint CREATE INDEX "idx_user_external_identities_user" ON "user_external_identities" USING btree ("user_id");--> statement-breakpoint CREATE UNIQUE INDEX "idx_user_second_factors_user_factor" ON "user_second_factors" USING btree ("user_id","plugin_id","factor_id"); -- ==== core 0032_nifty_hedge_knight ==== -- user_workspaces moved to the workspaces plugin, whose first migration renames it -- to p_workspaces_workspaces. Dropping it here would lose every saved workspace, -- so this only stops drizzle tracking it. SELECT 1 because MySQL rejects an -- empty query. SELECT 1; -- ==== core 0033_bent_trish_tilby ==== -- network_topology moved to the network-topology plugin, which adopts (renames) -- this table in its own migration before this drizzle migration would run. -- No DROP here: it would delete every row before the plugin's rename applies. SELECT 1; -- ==== core 0034_free_smiling_tiger ==== -- snippets, snippet_folders and snippet_access moved to the snippets plugin -- (p_snippets_*), adopted by rename rather than dropped. A real DROP TABLE -- here would run before the plugin's adoption migration and delete every row. SELECT 1; -- ==== core 0035_ambitious_klaw ==== -- dropped, see plugin adoption (fleets plugin, migrations/postgres/0001_adopt_fleets.sql) SELECT 1; -- ==== core 0036_redundant_ender_wiggin ==== -- proxmox_node_history and proxmox_stats_preferences moved to the proxmox -- plugin (p_proxmox_*), adopted by rename rather than dropped. The four -- ssh_data proxmox columns are copied into the plugin's host settings after -- plugins load, which is after this migration, so a real DROP COLUMN here -- would delete the data first. The columns stay in place, unused, until 3.0.0. SELECT 1; -- ==== core 0037_dizzy_sage ==== -- file_manager_pinned, file_manager_recent, file_manager_shortcuts and -- transfer_recent are adopted (renamed, not dropped) by the file-manager -- plugin's own migration, which runs at plugin activation, after core's -- drizzle migrations. A DROP TABLE here would run first and delete the data. SELECT 1; -- ==== core 0038_cute_vermin ==== -- c2s_tunnel_presets moved to the tunnels plugin, whose first migration renames -- it to p_tunnels_presets. Dropping it here would lose every saved preset, so -- this only stops drizzle tracking it. SELECT 1 because MySQL rejects an -- empty query. SELECT 1; -- ==== core 0039_violet_firedrake ==== -- command_history moved to the ssh-terminal plugin, whose first migration -- renames it to p_ssh_terminal_command_history. Dropping it here would lose -- every saved command, so this only stops drizzle tracking it. SELECT 1 -- because MySQL rejects an empty query. SELECT 1; -- ==== core 0040_narrow_hellion ==== -- tmux_session_tags moved to the tmux-monitor plugin, whose first migration -- renames it to p_tmux_monitor_session_tags. Dropping it here would lose -- every saved tag, so this only stops drizzle tracking it. SELECT 1 because -- MySQL rejects an empty query. SELECT 1; -- ==== core 0041_watery_zeigeist ==== -- session_shares, session_share_participants, collab_rooms and -- collab_room_members moved to the session-sharing plugin, whose first -- migration renames them. Dropping them here would lose every share and -- room, so this only stops drizzle tracking them. SELECT 1 because MySQL -- rejects an empty query. SELECT 1; -- ==== core 0042_strange_shocker ==== -- session_recordings moved to the session-recording plugin, whose first -- migration renames it. Dropping it here would lose every recording, so -- this only stops drizzle tracking it. SELECT 1 because MySQL rejects an -- empty query. SELECT 1; -- ==== core 0043_melodic_terror ==== -- The remote desktop host options (enable_rdp, enable_vnc, enable_telnet, -- the three ports, rdp_security, rdp_ignore_cert, security, ignore_cert, -- guacamole_config) and user_preferences.rdp_defaults moved to the -- remote-desktop plugin's settings. The copy runs after plugins load, which -- is after this migration, so a real DROP COLUMN here would delete the data -- first. The columns stay in place, unused, until 3.0.0. SELECT 1; -- ==== core 0044_nostalgic_omega_sentinel ==== -- host_metrics_preferences, host_health_checks, host_health_history and -- host_metrics_history moved to the host-metrics plugin, which adopts them by -- rename in its own first migration. That runs after this one, so a real -- DROP TABLE here would delete every row first. SELECT 1;--> statement-breakpoint -- Status checks are core: the per-host switch and interval, copied out of -- stats_config at boot by host-status-config-migration.ts. ALTER TABLE "ssh_data" ADD COLUMN "status_check_enabled" boolean DEFAULT true NOT NULL;--> statement-breakpoint ALTER TABLE "ssh_data" ADD COLUMN "status_check_interval" integer; -- ==== core 0045_thankful_shinobi_shaw ==== -- ssh_data.stats_config split: its status half moved to status_check_enabled -- and status_check_interval, its metrics half to the host-metrics plugin's -- host settings. Both copies run at boot, after this migration, so a real -- DROP COLUMN here would delete the data first. The column stays in place, -- unused, until 3.0.0. SELECT 1; -- ==== core 0046_small_white_tiger ==== -- ssh_data.enable_docker and docker_config moved to the docker plugin's host -- settings. The copy runs at boot, after this migration, so a real DROP -- COLUMN here would delete the data first. The columns stay in place, -- unused, until 3.0.0. SELECT 1; -- ==== core 0047_mighty_butterfly ==== -- The automation tables moved to the automations plugin, which renames them -- into its own namespace at activation. That runs after this migration, so a -- real DROP TABLE here would delete every automation first. SELECT 1; -- ==== core 0048_rare_catseye ==== -- The ai tables moved to the ai plugin, which renames them into its own -- namespace at activation, and ssh_data.enable_ai_assistant and the two -- user_preferences ai columns moved to its settings. Both run after this -- migration, so a real DROP here would delete the data first. The columns -- stay in place, unused, until 3.0.0. The timestamp and label type changes -- drizzle-kit also wrote are generator drift (see FINISH-LIST.md), not a -- change to the database, and are left out on purpose. SELECT 1; -- ==== core 0049_reflective_adam_destine ==== -- dashboard_service_links, homepage_items and homepage_layouts moved to the -- homepage plugin, which adopts them by rename at activation (see -- plugins/homepage/migrations/postgres/0001_adopt_homepage_tables.sql). -- Dropping them here would delete every row before the plugin's migration -- ever runs, since this runs at boot before the plugins table exists. SELECT 1; -- ==== core 0050_acoustic_lady_bullseye ==== -- mac_address and wol_broadcast_address move to the wake-on-lan plugin's -- host settings at boot, after this migration runs. Dropping them here would -- delete the data before the copy has a chance to run. SELECT 1; -- ==== core 0051_useful_slyde ==== -- secret_sources moves to the secret-sources plugin's adopted table at -- activation, after this migration runs. Dropping it here would delete the -- data before the plugin has a chance to rename it. SELECT 1; -- ==== core 0052_motionless_krista_starr ==== -- webauthn_credentials moves to the webauthn plugin's adopted table at -- activation, and the users TOTP columns are read by the TOTP boot migration -- after this runs. Dropping either here would lose the data first. SELECT 1; -- ==== core 0053_keen_thanos ==== -- sso_providers moves to the sso plugin's adopted table at activation, and -- its LDAP rows are copied into the ldap plugin by a boot migration after -- this runs. Dropping it here would lose the data first. SELECT 1; -- ==== core 0054_cloudy_galactus ==== -- opkssh_tokens moves to the opkssh plugin's adopted table at activation, -- and ssh_data.use_warpgate is copied into the warpgate plugin's host -- settings by a boot migration after this runs. Dropping either here would -- lose the data first. SELECT 1; -- ==== core 0055_jazzy_quasimodo ==== -- vault_profiles and vault_tokens move to the vault plugin's adopted tables -- at activation, and ssh_data.vault_profile_id is copied into the vault -- plugin's host settings by a boot migration after this runs. Dropping any -- of them here would lose the data first. SELECT 1; -- ==== core 0056_chilly_vindicator ==== -- termix_identities, termix_identity_keys and termix_identity_ca move to the -- termix-identity plugin's adopted tables at activation. Dropping them here -- would lose the data first. SELECT 1; -- ==== core 0057_married_dragon_lord ==== -- The dialect generator now decides varchar or text per table. Columns that -- were varchar(255) only because the same name was a key in another table -- become text, and the timestamps and labels B18's regeneration left as -- varchar(255) on real databases follow. varchar to text keeps every value. ALTER TABLE "api_keys" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "api_keys" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "api_keys" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "api_keys" ALTER COLUMN "expires_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "credential_access" ALTER COLUMN "expires_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "credential_access" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "credential_access" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "credential_sidebar_preferences" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "credential_sidebar_preferences" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "folder_access" ALTER COLUMN "expires_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "folder_access" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "folder_access" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "host_access" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "host_access" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "host_sidebar_preferences" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "host_sidebar_preferences" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "ssh_data" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_data" ALTER COLUMN "folder" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_data" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_data" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "ssh_data" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_data" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "notification_channels" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "notification_channels" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "notification_channels" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "plugin_install_counts" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "plugin_install_counts" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "plugin_registries" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "plugin_settings" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "plugin_settings" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "plugin_storage" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "plugin_storage" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "plugins" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "plugins" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "plugins" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "rbac_known_permissions" ALTER COLUMN "plugin_id" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "roles" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "roles" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "roles" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "roles" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "sessions" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "sessions" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "shared_credential_secrets" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "shared_credential_secrets" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "shared_credential_secrets" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "shared_credential_secrets" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "shared_host_auth_overrides" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "shared_host_auth_overrides" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "shared_host_auth_overrides" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "shared_host_auth_overrides" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "shared_host_secrets" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "shared_host_secrets" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "shared_host_secrets" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "shared_host_secrets" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "ssh_credentials" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_credentials" ALTER COLUMN "folder" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_credentials" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_credentials" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "ssh_credentials" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_credentials" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "ssh_folders" ALTER COLUMN "name" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_folders" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_folders" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "ssh_folders" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ssh_folders" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "sync_tombstones" ALTER COLUMN "sync_id" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "trusted_devices" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "trusted_devices" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "trusted_devices" ALTER COLUMN "expires_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ui_preferences" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "ui_preferences" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "user_external_identities" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "user_external_identities" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "user_open_tabs" ALTER COLUMN "label" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "user_open_tabs" ALTER COLUMN "created_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "user_open_tabs" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "user_open_tabs" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "user_open_tabs" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;--> statement-breakpoint ALTER TABLE "user_preferences" ALTER COLUMN "updated_at" SET DATA TYPE text;--> statement-breakpoint ALTER TABLE "user_preferences" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP; -- ==== core 0058_goofy_ma_gnuci ==== -- The file manager, tunnels, web endpoint, terminal, tmux monitor, session -- sharing and session recording host columns, and the dead show_*_in_sidebar -- columns, moved to their plugins' host settings. The copies run after -- plugins load, which is after this migration, so a real DROP COLUMN here -- would delete the data first. The columns stay in place, unused, until 3.0.0. SELECT 1; -- ==== core 0059_square_korg ==== -- dismissed_alerts and notification_channels moved to the alerts plugin. It -- renames the first into its own namespace and copies the second at -- activation, both after this migration, so a real DROP TABLE here would -- delete them first. notification_channels stays in place, unused, until -- 3.0.0. SELECT 1; -- ==== core 0060_conscious_juggernaut ==== CREATE TABLE "sync_conflicts" ( "id" serial PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "entity_type" text NOT NULL, "sync_id" text NOT NULL, "local_row" text NOT NULL, "server_revision" integer NOT NULL, "created_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint CREATE TABLE "sync_link" ( "id" serial PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "server_url" text NOT NULL, "server_name" text, "server_version" text, "session_token" text, "custom_headers" text, "basic_auth" text, "allow_invalid_certificate" boolean DEFAULT false NOT NULL, "remote_user_id" text, "remote_username" text, "account" text, "scope" text, "known_types" text, "cursor" integer DEFAULT 0 NOT NULL, "status" text DEFAULT 'idle' NOT NULL, "last_error" text, "linked_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, "last_sync_at" text ); --> statement-breakpoint CREATE TABLE "sync_records" ( "id" serial PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "entity_type" varchar(255) NOT NULL, "sync_id" varchar(255) NOT NULL, "revision" integer DEFAULT 0 NOT NULL, "seq" integer DEFAULT 0 NOT NULL, "hash" text, "deleted" boolean DEFAULT false NOT NULL, "error" text, "error_hash" text, "updated_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "ssh_data" ADD COLUMN "local_only" boolean DEFAULT false NOT NULL;--> statement-breakpoint ALTER TABLE "ssh_data" ADD COLUMN "shared_source" text;--> statement-breakpoint ALTER TABLE "ssh_credentials" ADD COLUMN "shared_source" text;--> statement-breakpoint ALTER TABLE "ssh_folders" ADD COLUMN "local_only" boolean DEFAULT false NOT NULL;--> statement-breakpoint ALTER TABLE "sync_conflicts" ADD CONSTRAINT "sync_conflicts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "sync_link" ADD CONSTRAINT "sync_link_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "sync_records" ADD CONSTRAINT "sync_records_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE INDEX "idx_sync_conflicts_user" ON "sync_conflicts" USING btree ("user_id");--> statement-breakpoint CREATE UNIQUE INDEX "idx_sync_records_user_entity_sync" ON "sync_records" USING btree ("user_id","entity_type","sync_id");--> statement-breakpoint CREATE INDEX "idx_sync_records_user_seq" ON "sync_records" USING btree ("user_id","seq"); -- ==== core 0061_red_lila_cheney ==== DROP TABLE "sync_tombstones" CASCADE; -- ==== core 0062_curvy_killmonger ==== ALTER TABLE "ssh_data" ADD COLUMN "ssh_options" text; -- ==== core 0063_giant_starfox ==== -- The RDP, VNC and Telnet logins moved out of ssh_data into host_protocol_auth. -- A boot migration copies them after this runs, so the old ssh_data columns -- and their foreign keys stay in place, unused, until 3.0.0. CREATE TABLE "host_protocol_auth" ( "id" serial PRIMARY KEY NOT NULL, "host_id" integer NOT NULL, "user_id" varchar(255) NOT NULL, "protocol" varchar(255) NOT NULL, "auth_type" text DEFAULT 'direct' NOT NULL, "credential_id" integer, "username" text, "password" text, "fields" text, "secret_fields" text, "created_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL, "updated_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "shared_host_secrets" ADD COLUMN "encrypted_fields" text;--> statement-breakpoint ALTER TABLE "host_protocol_auth" ADD CONSTRAINT "host_protocol_auth_host_id_ssh_data_id_fk" FOREIGN KEY ("host_id") REFERENCES "public"."ssh_data"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "host_protocol_auth" ADD CONSTRAINT "host_protocol_auth_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "host_protocol_auth" ADD CONSTRAINT "host_protocol_auth_credential_id_ssh_credentials_id_fk" FOREIGN KEY ("credential_id") REFERENCES "public"."ssh_credentials"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "idx_host_protocol_auth_host_protocol" ON "host_protocol_auth" USING btree ("host_id","protocol");--> statement-breakpoint CREATE INDEX "idx_host_protocol_auth_user" ON "host_protocol_auth" USING btree ("user_id");--> statement-breakpoint CREATE INDEX "idx_host_protocol_auth_credential" ON "host_protocol_auth" USING btree ("credential_id"); -- ==== core 0064_sticky_pestilence ==== -- ssh_data.autostart_password, autostart_key and autostart_key_password held -- copies of a host's login for 2.8's autostart endpoint, which nothing has read -- since. They leave the schema but stay in place, unused, until 3.0.0, so no -- install loses what it stored. SELECT 1; -- ==== core 0065_regular_joystick ==== CREATE TABLE "host_defaults" ( "id" serial PRIMARY KEY NOT NULL, "level" text NOT NULL, "scope_key" varchar(255) NOT NULL, "user_id" varchar(255), "folder_id" integer, "namespace" varchar(255) NOT NULL, "key" varchar(255) NOT NULL, "value" text, "updated_by" text, "updated_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL ); --> statement-breakpoint ALTER TABLE "ssh_data" ADD COLUMN "default_overrides" text;--> statement-breakpoint ALTER TABLE "host_defaults" ADD CONSTRAINT "host_defaults_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "host_defaults" ADD CONSTRAINT "host_defaults_folder_id_ssh_folders_id_fk" FOREIGN KEY ("folder_id") REFERENCES "public"."ssh_folders"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "idx_host_defaults_scope_key" ON "host_defaults" USING btree ("scope_key","namespace","key");--> statement-breakpoint CREATE INDEX "idx_host_defaults_user" ON "host_defaults" USING btree ("user_id");--> statement-breakpoint CREATE INDEX "idx_host_defaults_folder" ON "host_defaults" USING btree ("folder_id"); -- ==== plugin workspaces 0001_adopt_user_workspaces.sql ==== -- workspaces 0001: adopt_user_workspaces -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "user_workspaces" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "color" text, "icon" text, "kind" text NOT NULL DEFAULT 'manual', "is_default" boolean NOT NULL DEFAULT false, "payload" text NOT NULL DEFAULT '{}', "sync_id" varchar(255) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "last_used_at" text, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_user_workspaces_user_id" ON "user_workspaces" ("user_id"); ALTER TABLE "user_workspaces" RENAME TO "p_workspaces_workspaces"; -- ==== plugin network-topology 0001_adopt_network_topology.sql ==== -- network-topology 0001: adopt_network_topology -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "network_topology" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "topology" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "network_topology" RENAME TO "p_network_topology_graphs"; -- ==== plugin snippets 0001_adopt_snippets_tables.sql ==== -- snippets 0001: adopt_snippets_tables -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "snippets" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "content" text NOT NULL, "description" text, "folder" text, "order" integer NOT NULL DEFAULT 0, "sync_id" varchar(255) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "host_filter" text, "is_note" boolean NOT NULL DEFAULT false, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_snippets_user_id" ON "snippets" ("user_id"); ALTER TABLE "snippets" RENAME TO "p_snippets_snippets"; CREATE TABLE IF NOT EXISTS "snippet_folders" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "color" text, "icon" text, "sync_id" varchar(255) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "snippet_folders" RENAME TO "p_snippets_snippet_folders"; CREATE TABLE IF NOT EXISTS "snippet_access" ( "id" serial PRIMARY KEY, "snippet_id" integer NOT NULL, "user_id" varchar(255), "role_id" integer, "granted_by" varchar(255) NOT NULL, "permission_level" text NOT NULL DEFAULT 'view', "expires_at" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("granted_by") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_snippet_access_user_id" ON "snippet_access" ("user_id"); CREATE INDEX IF NOT EXISTS "idx_snippet_access_snippet_id" ON "snippet_access" ("snippet_id"); CREATE INDEX IF NOT EXISTS "idx_snippet_access_role_id" ON "snippet_access" ("role_id"); ALTER TABLE "snippet_access" RENAME TO "p_snippets_snippet_access"; -- ==== plugin fleets 0001_adopt_fleets.sql ==== -- fleets 0001: adopt_fleets -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "fleets" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "description" text, "color" text, "icon" text, "tag_rules" text, "sync_id" varchar(255) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "fleets" RENAME TO "p_fleets_fleets"; CREATE TABLE IF NOT EXISTS "fleet_members" ( "id" serial PRIMARY KEY, "fleet_id" integer NOT NULL, "host_id" integer NOT NULL, "added_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("fleet_id") REFERENCES "p_fleets_fleets" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_fleet_members_fleet_host" ON "fleet_members" ("fleet_id", "host_id"); CREATE INDEX IF NOT EXISTS "idx_fleet_members_host" ON "fleet_members" ("host_id"); ALTER TABLE "fleet_members" RENAME TO "p_fleets_members"; CREATE TABLE IF NOT EXISTS "fleet_inventory" ( "id" serial PRIMARY KEY, "host_id" integer NOT NULL, "user_id" varchar(255) NOT NULL, "os_pretty_name" text, "kernel" text, "architecture" text, "hostname" text, "uptime_seconds" integer, "ip" text, "package_manager" text, "collected_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_fleet_inventory_host" ON "fleet_inventory" ("host_id", "user_id"); CREATE INDEX IF NOT EXISTS "idx_fleet_inventory_user" ON "fleet_inventory" ("user_id"); ALTER TABLE "fleet_inventory" RENAME TO "p_fleets_inventory"; -- ==== plugin ssh-terminal 0001_adopt_command_history.sql ==== -- ssh-terminal 0001: adopt_command_history -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "command_history" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "command" text NOT NULL, "executed_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_command_history_user_host" ON "command_history" ("user_id", "host_id"); ALTER TABLE "command_history" RENAME TO "p_ssh_terminal_command_history"; -- ==== plugin tunnels 0001_adopt_c2s_tunnel_presets.sql ==== -- tunnels 0001: adopt_c2s_tunnel_presets -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "c2s_tunnel_presets" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text 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, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "c2s_tunnel_presets" RENAME TO "p_tunnels_presets"; -- ==== plugin host-metrics 0001_adopt_host_metrics_tables.sql ==== -- host-metrics 0001: adopt_host_metrics_tables -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "host_metrics_preferences" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "layout" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_host_metrics_prefs_user_host" ON "host_metrics_preferences" ("user_id", "host_id"); ALTER TABLE "host_metrics_preferences" RENAME TO "p_host_metrics_host_metrics_preferences"; CREATE TABLE IF NOT EXISTS "host_health_checks" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "checks" text NOT NULL, "interval_seconds" integer NOT NULL DEFAULT 300, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_host_health_checks_user_host" ON "host_health_checks" ("user_id", "host_id"); ALTER TABLE "host_health_checks" RENAME TO "p_host_metrics_host_health_checks"; CREATE TABLE IF NOT EXISTS "host_health_history" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "check_id" varchar(255) NOT NULL, "ts" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, "ok" boolean NOT NULL, "latency_ms" integer, "detail" text, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_host_health_history_lookup" ON "host_health_history" ("user_id", "host_id", "check_id", "ts"); ALTER TABLE "host_health_history" RENAME TO "p_host_metrics_host_health_history"; CREATE TABLE IF NOT EXISTS "host_metrics_history" ( "id" serial PRIMARY KEY, "host_id" integer NOT NULL, "ts" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, "cpu_percent" double precision, "mem_percent" double precision, "disk_percent" double precision, "net_rx_bytes" integer, "net_tx_bytes" integer, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_host_metrics_history_host_ts" ON "host_metrics_history" ("host_id", "ts"); ALTER TABLE "host_metrics_history" RENAME TO "p_host_metrics_host_metrics_history"; -- ==== plugin automations 0001_adopt_automations.sql ==== -- automations 0001: adopt_automations -- Generated by termix-plugin migrations. Review before committing. -- Hand-edited: keeps the legacy foreign keys the SDK cannot declare -- (links between these tables, and a channel link to notification_channels). CREATE TABLE IF NOT EXISTS "automations" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "description" text, "enabled" boolean NOT NULL DEFAULT true, "definition" text NOT NULL, "definition_version" integer NOT NULL DEFAULT 1, "concurrency_policy" text NOT NULL DEFAULT 'skip', "max_run_seconds" integer NOT NULL DEFAULT 300, "dry_run" boolean NOT NULL DEFAULT false, "last_run_at" text, "last_run_status" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_automations_user" ON "automations" ("user_id", "enabled"); ALTER TABLE "automations" RENAME TO "p_automations_automations"; CREATE TABLE IF NOT EXISTS "automation_trigger_state" ( "id" serial PRIMARY KEY, "automation_id" integer NOT NULL, "state_key" varchar(255) NOT NULL, "breach_started_at" text, "last_fired_at" text, "last_value" double precision, "last_observed_state" text, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("automation_id") REFERENCES "p_automations_automations" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_automation_trigger_state_key" ON "automation_trigger_state" ("automation_id", "state_key"); ALTER TABLE "automation_trigger_state" RENAME TO "p_automations_trigger_state"; CREATE TABLE IF NOT EXISTS "automation_schedules" ( "id" serial PRIMARY KEY, "automation_id" integer NOT NULL, "cron" text, "interval_seconds" integer, "timezone" text, "next_due_at" varchar(255), "last_tick_at" text, FOREIGN KEY ("automation_id") REFERENCES "p_automations_automations" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_automation_schedules_automation" ON "automation_schedules" ("automation_id"); CREATE INDEX IF NOT EXISTS "idx_automation_schedules_due" ON "automation_schedules" ("next_due_at"); ALTER TABLE "automation_schedules" RENAME TO "p_automations_schedules"; CREATE TABLE IF NOT EXISTS "automation_runs" ( "id" serial PRIMARY KEY, "automation_id" integer NOT NULL, "user_id" varchar(255) NOT NULL, "trigger_type" text NOT NULL, "trigger_context" text, "status" text NOT NULL, "started_at" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, "finished_at" text, "duration_ms" integer, "error" text, "dry_run" boolean NOT NULL DEFAULT false, "parent_run_id" integer, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("automation_id") REFERENCES "p_automations_automations" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_automation_runs_automation" ON "automation_runs" ("automation_id", "started_at"); CREATE INDEX IF NOT EXISTS "idx_automation_runs_user" ON "automation_runs" ("user_id", "started_at"); ALTER TABLE "automation_runs" RENAME TO "p_automations_runs"; CREATE TABLE IF NOT EXISTS "automation_run_steps" ( "id" serial PRIMARY KEY, "run_id" integer NOT NULL, "step_index" integer NOT NULL, "step_id" text NOT NULL, "step_type" text NOT NULL, "status" text NOT NULL, "started_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "finished_at" text, "output" text, "error" text, "truncated" boolean NOT NULL DEFAULT false, FOREIGN KEY ("run_id") REFERENCES "p_automations_runs" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_automation_run_steps_run" ON "automation_run_steps" ("run_id", "step_index"); ALTER TABLE "automation_run_steps" RENAME TO "p_automations_run_steps"; CREATE TABLE IF NOT EXISTS "automation_channels" ( "id" serial PRIMARY KEY, "automation_id" integer NOT NULL, "channel_id" integer NOT NULL, FOREIGN KEY ("automation_id") REFERENCES "p_automations_automations" ("id") ON DELETE CASCADE, FOREIGN KEY ("channel_id") REFERENCES "notification_channels" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_automation_channels_pair" ON "automation_channels" ("automation_id", "channel_id"); ALTER TABLE "automation_channels" RENAME TO "p_automations_channels"; -- ==== plugin automations 0002_unlink_channels.sql ==== -- automations 0002: unlink_channels -- Hand-written: channels moved from core's notification_channels to the -- alerts plugin, so the link table drops its foreign key to the old table. -- The constraint's name differs between installs, so the table is rebuilt. CREATE TABLE IF NOT EXISTS "p_automations_channels_v2" ( "id" serial PRIMARY KEY, "automation_id" integer NOT NULL, "channel_id" integer NOT NULL, FOREIGN KEY ("automation_id") REFERENCES "p_automations_automations" ("id") ON DELETE CASCADE ); INSERT INTO "p_automations_channels_v2" ("id", "automation_id", "channel_id") SELECT "id", "automation_id", "channel_id" FROM "p_automations_channels"; DROP TABLE "p_automations_channels"; ALTER TABLE "p_automations_channels_v2" RENAME TO "p_automations_channels"; SELECT setval(pg_get_serial_sequence('p_automations_channels', 'id'), COALESCE((SELECT MAX("id") FROM "p_automations_channels"), 1)); CREATE UNIQUE INDEX IF NOT EXISTS "idx_automation_channels_pair" ON "p_automations_channels" ("automation_id", "channel_id"); -- ==== plugin homepage 0001_adopt_homepage_tables.sql ==== -- homepage 0001: adopt_homepage_tables -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "homepage_items" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "type_id" text NOT NULL, "title" text, "config" text NOT NULL DEFAULT '{}', "folder_id" integer, "sync_id" varchar(255) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_homepage_items_user_id" ON "homepage_items" ("user_id"); ALTER TABLE "homepage_items" RENAME TO "p_homepage_homepage_items"; CREATE TABLE IF NOT EXISTS "homepage_layouts" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL UNIQUE, "layout" text NOT NULL DEFAULT '{}', "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "homepage_layouts" RENAME TO "p_homepage_homepage_layouts"; CREATE TABLE IF NOT EXISTS "dashboard_service_links" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "label" text NOT NULL, "url" text NOT NULL, "order" integer NOT NULL DEFAULT 0, "sync_id" varchar(255) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_dashboard_service_links_user_id" ON "dashboard_service_links" ("user_id"); ALTER TABLE "dashboard_service_links" RENAME TO "p_homepage_dashboard_service_links"; -- ==== plugin ai 0001_adopt_ai_tables.sql ==== -- ai 0001: adopt_ai_tables -- Generated by termix-plugin migrations. Review before committing. -- Hand-edited: keeps the legacy foreign key from messages and proposals to -- their conversation, which the SDK cannot declare. CREATE TABLE IF NOT EXISTS "ai_providers" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "provider_type" text NOT NULL, "label" varchar(255) NOT NULL, "base_url" text, "api_key_prefix" text, "default_model" text, "enabled" boolean NOT NULL DEFAULT true, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_ai_providers_user_label" ON "ai_providers" ("user_id", "label"); ALTER TABLE "ai_providers" RENAME TO "p_ai_providers"; CREATE TABLE IF NOT EXISTS "ai_conversations" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "title" text, "provider_id" integer, "model" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_ai_conversations_user" ON "ai_conversations" ("user_id", "updated_at"); ALTER TABLE "ai_conversations" RENAME TO "p_ai_conversations"; CREATE TABLE IF NOT EXISTS "ai_messages" ( "id" serial PRIMARY KEY, "conversation_id" integer NOT NULL, "role" text NOT NULL, "content" text NOT NULL DEFAULT '', "tool_calls" text, "created_at" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("conversation_id") REFERENCES "p_ai_conversations" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_ai_messages_conversation" ON "ai_messages" ("conversation_id", "created_at"); ALTER TABLE "ai_messages" RENAME TO "p_ai_messages"; CREATE TABLE IF NOT EXISTS "ai_proposals" ( "id" serial PRIMARY KEY, "conversation_id" integer NOT NULL, "user_id" varchar(255) NOT NULL, "kind" varchar(255) NOT NULL, "summary" text, "payload" text NOT NULL DEFAULT '{}', "status" varchar(32) NOT NULL DEFAULT 'pending', "applied_at" text, "result_summary" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("conversation_id") REFERENCES "p_ai_conversations" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_ai_proposals_user" ON "ai_proposals" ("user_id", "status"); CREATE INDEX IF NOT EXISTS "idx_ai_proposals_conversation" ON "ai_proposals" ("conversation_id"); ALTER TABLE "ai_proposals" RENAME TO "p_ai_proposals"; -- ==== plugin ai 0002_provider_sync.sql ==== ALTER TABLE "p_ai_providers" ADD COLUMN "sync_id" varchar(255) UNIQUE; -- ==== plugin alerts 0001_create_alerts.sql ==== -- alerts 0001: create_alerts -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "p_alerts_channels" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "type" varchar(32) NOT NULL, "config" text, "enabled" boolean NOT NULL DEFAULT true, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_alerts_channels_user" ON "p_alerts_channels" ("user_id"); CREATE TABLE IF NOT EXISTS "p_alerts_items" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "source" varchar(64) NOT NULL, "category" varchar(128) NOT NULL, "severity" varchar(16) NOT NULL, "title" text NOT NULL, "body" text, "link" text, "context" text, "dedupe_key" varchar(255), "deliveries" text, "read_at" varchar(255), "created_at" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_alerts_items_user" ON "p_alerts_items" ("user_id", "created_at"); CREATE INDEX IF NOT EXISTS "idx_alerts_items_unread" ON "p_alerts_items" ("user_id", "read_at"); CREATE INDEX IF NOT EXISTS "idx_alerts_items_dedupe" ON "p_alerts_items" ("user_id", "dedupe_key"); CREATE TABLE IF NOT EXISTS "p_alerts_rules" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "pattern" varchar(128) NOT NULL DEFAULT '*', "min_severity" varchar(16) NOT NULL DEFAULT 'warning', "channel_ids" text NOT NULL, "enabled" boolean NOT NULL DEFAULT true, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_alerts_rules_user" ON "p_alerts_rules" ("user_id"); CREATE TABLE IF NOT EXISTS "dismissed_alerts" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "alert_id" text NOT NULL, "dismissed_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_dismissed_alerts_user_id" ON "dismissed_alerts" ("user_id"); ALTER TABLE "dismissed_alerts" RENAME TO "p_alerts_dismissed"; -- ==== plugin file-manager 0001_adopt_file_manager_tables.sql ==== -- file-manager 0001: adopt_file_manager_tables -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "file_manager_recent" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "name" text NOT NULL, "path" text NOT NULL, "last_opened" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_file_manager_recent_user" ON "file_manager_recent" ("user_id", "host_id"); ALTER TABLE "file_manager_recent" RENAME TO "p_file_manager_recent"; CREATE TABLE IF NOT EXISTS "file_manager_pinned" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "name" text NOT NULL, "path" text NOT NULL, "pinned_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_file_manager_pinned_user" ON "file_manager_pinned" ("user_id", "host_id"); ALTER TABLE "file_manager_pinned" RENAME TO "p_file_manager_pinned"; CREATE TABLE IF NOT EXISTS "file_manager_shortcuts" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "name" text NOT NULL, "path" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_file_manager_shortcuts_user" ON "file_manager_shortcuts" ("user_id", "host_id"); ALTER TABLE "file_manager_shortcuts" RENAME TO "p_file_manager_shortcuts"; CREATE TABLE IF NOT EXISTS "transfer_recent" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "source_host_id" integer NOT NULL, "dest_host_id" integer NOT NULL, "dest_path" text NOT NULL, "dest_path_label" text NOT NULL, "last_used" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("source_host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE, FOREIGN KEY ("dest_host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_transfer_recent_user" ON "transfer_recent" ("user_id"); ALTER TABLE "transfer_recent" RENAME TO "p_file_manager_transfer_recent"; -- ==== plugin ldap 0001_create_providers.sql ==== -- ldap 0001: create_providers -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "p_ldap_providers" ( "id" serial PRIMARY KEY, "name" text NOT NULL, "enabled" boolean NOT NULL DEFAULT true, "display_order" integer NOT NULL DEFAULT 0, "config" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP ); -- ==== plugin opkssh 0001_adopt_opkssh_tokens.sql ==== -- opkssh 0001: adopt_opkssh_tokens -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "opkssh_tokens" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer 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" varchar(255) NOT NULL, "last_used" text, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_opkssh_tokens_user_host" ON "opkssh_tokens" ("user_id", "host_id"); ALTER TABLE "opkssh_tokens" RENAME TO "p_opkssh_tokens"; -- ==== plugin proxmox 0001_adopt_proxmox_stats.sql ==== -- proxmox 0001: adopt_proxmox_stats -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "proxmox_node_history" ( "id" serial PRIMARY KEY, "host_id" integer NOT NULL, "ts" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "cpu_percent" double precision, "mem_percent" double precision, "disk_percent" double precision, "net_rx_bytes" integer, "net_tx_bytes" integer, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); ALTER TABLE "proxmox_node_history" RENAME TO "p_proxmox_node_history"; CREATE TABLE IF NOT EXISTS "proxmox_stats_preferences" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "layout" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_proxmox_stats_prefs_user_host" ON "proxmox_stats_preferences" ("user_id", "host_id"); ALTER TABLE "proxmox_stats_preferences" RENAME TO "p_proxmox_stats_preferences"; -- ==== plugin session-recording 0001_adopt_session_recordings.sql ==== -- session-recording 0001: adopt_session_recordings -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "session_recordings" ( "id" serial PRIMARY KEY, "host_id" integer NOT NULL, "user_id" varchar(255), "username" text, "access_id" integer, "started_at" varchar(255) NOT NULL DEFAULT CURRENT_TIMESTAMP, "ended_at" text, "duration" integer, "commands" text, "dangerous_actions" text, "recording_path" text, "protocol" text NOT NULL DEFAULT 'ssh', "format" text NOT NULL DEFAULT 'text', "terminated_by_owner" boolean DEFAULT false, "termination_reason" text, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_session_recordings_user_started" ON "session_recordings" ("user_id", "started_at"); CREATE INDEX IF NOT EXISTS "idx_session_recordings_host" ON "session_recordings" ("host_id"); ALTER TABLE "session_recordings" RENAME TO "p_session_recording_session_recordings"; -- ==== plugin secret-sources 0001_adopt_secret_sources.sql ==== -- secret-sources 0001: adopt_secret_sources -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "secret_sources" ( "id" varchar(255) PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "kind" text NOT NULL DEFAULT 'onepassword-connect', "base_url" text NOT NULL, "shared" boolean NOT NULL DEFAULT false, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_secret_sources_user" ON "secret_sources" ("user_id"); ALTER TABLE "secret_sources" RENAME TO "p_secret_sources_sources"; -- ==== plugin session-sharing 0001_adopt_session_sharing.sql ==== -- session-sharing 0001: adopt_session_sharing -- Generated by termix-plugin migrations. Review before committing. -- Hand-edited: keeps the legacy foreign keys the SDK cannot declare -- (nullable or set-null user and host links, and links between these tables). CREATE TABLE IF NOT EXISTS "session_shares" ( "id" varchar(255) PRIMARY KEY NOT NULL, "host_id" integer NOT NULL, "owner_user_id" varchar(255) NOT NULL, "protocol" text NOT NULL, "session_id" varchar(255) NOT NULL, "tab_instance_id" text, "share_type" text NOT NULL, "target_user_id" varchar(255), "link_token" varchar(255) UNIQUE, "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" integer NOT NULL DEFAULT 0, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE, FOREIGN KEY ("owner_user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS "idx_session_shares_session_id" ON "session_shares" ("session_id"); CREATE INDEX IF NOT EXISTS "idx_session_shares_host_id" ON "session_shares" ("host_id"); ALTER TABLE "session_shares" RENAME TO "p_session_sharing_shares"; CREATE TABLE IF NOT EXISTS "session_share_participants" ( "id" serial PRIMARY KEY, "share_id" varchar(255) NOT NULL, "user_id" varchar(255), "guest_label" text, "joined_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "left_at" text, FOREIGN KEY ("share_id") REFERENCES "p_session_sharing_shares" ("id") ON DELETE CASCADE, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "session_share_participants" RENAME TO "p_session_sharing_share_participants"; CREATE TABLE IF NOT EXISTS "collab_rooms" ( "id" varchar(255) PRIMARY KEY NOT NULL, "name" text NOT NULL, "owner_user_id" varchar(255) NOT NULL, "persistent" boolean NOT NULL DEFAULT false, "presenter_user_id" varchar(255), "stage_protocol" text, "stage_host_id" integer, "stage_share_id" varchar(255), "guest_link_token" varchar(255), "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "ended_at" text, FOREIGN KEY ("owner_user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("presenter_user_id") REFERENCES "users" ("id") ON DELETE SET NULL, FOREIGN KEY ("stage_host_id") REFERENCES "ssh_data" ("id") ON DELETE SET NULL, FOREIGN KEY ("stage_share_id") REFERENCES "p_session_sharing_shares" ("id") ON DELETE SET NULL ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_collab_rooms_guest_token" ON "collab_rooms" ("guest_link_token"); CREATE INDEX IF NOT EXISTS "idx_collab_rooms_owner" ON "collab_rooms" ("owner_user_id"); ALTER TABLE "collab_rooms" RENAME TO "p_session_sharing_rooms"; CREATE TABLE IF NOT EXISTS "collab_room_members" ( "id" serial PRIMARY KEY, "room_id" varchar(255) NOT NULL, "user_id" varchar(255) NOT NULL, "room_role" text NOT NULL DEFAULT 'member', "added_by" varchar(255), "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("room_id") REFERENCES "p_session_sharing_rooms" ("id") ON DELETE CASCADE, FOREIGN KEY ("added_by") REFERENCES "users" ("id") ON DELETE SET NULL ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_collab_room_members_room_user" ON "collab_room_members" ("room_id", "user_id"); CREATE INDEX IF NOT EXISTS "idx_collab_room_members_user" ON "collab_room_members" ("user_id"); ALTER TABLE "collab_room_members" RENAME TO "p_session_sharing_room_members"; -- ==== plugin sso 0001_adopt_sso_providers.sql ==== -- sso 0001: adopt_sso_providers -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "sso_providers" ( "id" serial PRIMARY KEY, "name" text NOT NULL, "type" text NOT NULL, "enabled" boolean NOT NULL DEFAULT true, "display_order" integer NOT NULL DEFAULT 0, "config" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE "sso_providers" RENAME TO "p_sso_providers"; -- ==== plugin sso 0002_legacy_callback.sql ==== -- sso 0002: legacy_callback -- Generated by termix-plugin migrations. Review before committing. ALTER TABLE "p_sso_providers" ADD COLUMN "legacy_callback" boolean NOT NULL DEFAULT false; -- Providers that existed before 2.9 were registered with the identity -- provider under /users/oidc/callback, so they keep sending that URI. UPDATE "p_sso_providers" SET "legacy_callback" = true; -- ==== plugin step-ca 0001_create_certs.sql ==== -- step-ca 0001: create_certs -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "p_step_ca_certs" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "ssh_cert" text NOT NULL, "private_key" text NOT NULL, "email" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "expires_at" varchar(255) NOT NULL, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_step_ca_certs_user_host" ON "p_step_ca_certs" ("user_id", "host_id"); -- ==== plugin termix-identity 0001_adopt_termix_identity_tables.sql ==== -- termix-identity 0001: adopt_termix_identity_tables -- Generated by termix-plugin migrations. Review before committing. -- Hand-edited: keeps the legacy foreign keys the SDK cannot declare -- (keys and ca to their identity, keys to ssh_credentials). CREATE TABLE IF NOT EXISTS "termix_identities" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL UNIQUE, "handle" varchar(255) NOT NULL UNIQUE, "description" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "termix_identities" RENAME TO "p_termix_identity_identities"; CREATE TABLE IF NOT EXISTS "termix_identity_keys" ( "id" serial PRIMARY KEY, "identity_id" integer 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" integer, "enabled" boolean NOT NULL DEFAULT true, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("identity_id") REFERENCES "p_termix_identity_identities" ("id") ON DELETE CASCADE, FOREIGN KEY ("credential_id") REFERENCES "ssh_credentials" ("id") ON DELETE SET NULL ); CREATE INDEX IF NOT EXISTS "idx_termix_identity_keys_identity" ON "termix_identity_keys" ("identity_id"); ALTER TABLE "termix_identity_keys" RENAME TO "p_termix_identity_keys"; CREATE TABLE IF NOT EXISTS "termix_identity_ca" ( "id" serial PRIMARY KEY, "identity_id" integer NOT NULL UNIQUE, "user_id" varchar(255) NOT NULL, "public_key" text NOT NULL, "private_key" text NOT NULL, "validity_days" integer NOT NULL DEFAULT 90, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("identity_id") REFERENCES "p_termix_identity_identities" ("id") ON DELETE CASCADE ); ALTER TABLE "termix_identity_ca" RENAME TO "p_termix_identity_ca"; -- ==== plugin tmux-monitor 0001_adopt_tmux_session_tags.sql ==== -- tmux-monitor 0001: adopt_tmux_session_tags -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "tmux_session_tags" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "host_id" integer NOT NULL, "session_name" text NOT NULL, "tag" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE, FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE ); ALTER TABLE "tmux_session_tags" RENAME TO "p_tmux_monitor_session_tags"; -- ==== plugin totp 0001_create_enrollments.sql ==== -- totp 0001: create_enrollments -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "p_totp_enrollments" ( "user_id" varchar(255) PRIMARY KEY NOT NULL, "secret" text, "pending_secret" text, "backup_codes" text, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); -- ==== plugin vault 0001_adopt_vault_tables.sql ==== -- vault 0001: adopt_vault_tables -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "vault_profiles" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "name" text 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) UNIQUE, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "vault_profiles" RENAME TO "p_vault_profiles"; CREATE TABLE IF NOT EXISTS "vault_tokens" ( "id" serial PRIMARY KEY, "user_id" varchar(255) NOT NULL, "profile_id" integer NOT NULL, "ssh_cert" text NOT NULL, "private_key" text NOT NULL, "created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP, "expires_at" varchar(255) NOT NULL, "last_used" text, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS "idx_vault_tokens_user_profile" ON "vault_tokens" ("user_id", "profile_id"); ALTER TABLE "vault_tokens" RENAME TO "p_vault_tokens"; -- ==== plugin webauthn 0001_adopt_webauthn_credentials.sql ==== -- webauthn 0001: adopt_webauthn_credentials -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS "webauthn_credentials" ( "id" varchar(255) PRIMARY KEY NOT NULL, "user_id" varchar(255) NOT NULL, "name" text NOT NULL, "credential_id" varchar(255) NOT NULL UNIQUE, "public_key" text NOT NULL, "counter" integer 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, FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ); ALTER TABLE "webauthn_credentials" RENAME TO "p_webauthn_credentials";