mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
feat: move session sharing and collab rooms into a plugin (B12)
This commit is contained in:
1 parent
791d8656a1
commit
a276f6898c
207 files changed
+35771
-11072
No files matched your search
@@ -0,0 +1,67 @@
|
||||
-- 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` int 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` int 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
|
||||
);
|
||||
RENAME TABLE `session_shares` TO `p_session_sharing_shares`;
|
||||
CREATE TABLE IF NOT EXISTS `session_share_participants` (
|
||||
`id` int AUTO_INCREMENT 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
|
||||
);
|
||||
RENAME TABLE `session_share_participants` 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` int,
|
||||
`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
|
||||
);
|
||||
RENAME TABLE `collab_rooms` TO `p_session_sharing_rooms`;
|
||||
CREATE TABLE IF NOT EXISTS `collab_room_members` (
|
||||
`id` int AUTO_INCREMENT 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
|
||||
);
|
||||
RENAME TABLE `collab_room_members` TO `p_session_sharing_room_members`;
|
||||
@@ -0,0 +1,73 @@
|
||||
-- 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";
|
||||
@@ -0,0 +1,223 @@
|
||||
{
|
||||
"version": 1,
|
||||
"tables": {
|
||||
"shares": {
|
||||
"columns": {
|
||||
"id": {
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"hostId": {
|
||||
"type": "refHost",
|
||||
"notNull": true
|
||||
},
|
||||
"ownerUserId": {
|
||||
"type": "refUser",
|
||||
"length": 255,
|
||||
"notNull": true
|
||||
},
|
||||
"protocol": {
|
||||
"type": "text",
|
||||
"notNull": true
|
||||
},
|
||||
"sessionId": {
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"notNull": true
|
||||
},
|
||||
"tabInstanceId": {
|
||||
"type": "text"
|
||||
},
|
||||
"shareType": {
|
||||
"type": "text",
|
||||
"notNull": true
|
||||
},
|
||||
"targetUserId": {
|
||||
"type": "varchar",
|
||||
"length": 255
|
||||
},
|
||||
"linkToken": {
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"unique": true
|
||||
},
|
||||
"permissionLevel": {
|
||||
"type": "text",
|
||||
"notNull": true,
|
||||
"defaultValue": "read-only"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "timestamp",
|
||||
"notNull": true,
|
||||
"defaultNow": true
|
||||
},
|
||||
"expiresAt": {
|
||||
"type": "text",
|
||||
"notNull": true
|
||||
},
|
||||
"revokedAt": {
|
||||
"type": "text"
|
||||
},
|
||||
"lastJoinedAt": {
|
||||
"type": "text"
|
||||
},
|
||||
"joinCount": {
|
||||
"type": "integer",
|
||||
"notNull": true,
|
||||
"defaultValue": 0
|
||||
}
|
||||
},
|
||||
"indexes": [
|
||||
{
|
||||
"name": "idx_session_shares_session_id",
|
||||
"columns": ["sessionId"]
|
||||
},
|
||||
{
|
||||
"name": "idx_session_shares_host_id",
|
||||
"columns": ["hostId"]
|
||||
}
|
||||
],
|
||||
"adopts": "session_shares"
|
||||
},
|
||||
"share_participants": {
|
||||
"columns": {
|
||||
"id": {
|
||||
"type": "id",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"shareId": {
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"notNull": true
|
||||
},
|
||||
"userId": {
|
||||
"type": "varchar",
|
||||
"length": 255
|
||||
},
|
||||
"guestLabel": {
|
||||
"type": "text"
|
||||
},
|
||||
"joinedAt": {
|
||||
"type": "timestamp",
|
||||
"notNull": true,
|
||||
"defaultNow": true
|
||||
},
|
||||
"leftAt": {
|
||||
"type": "text"
|
||||
}
|
||||
},
|
||||
"indexes": [],
|
||||
"adopts": "session_share_participants"
|
||||
},
|
||||
"rooms": {
|
||||
"columns": {
|
||||
"id": {
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"type": "text",
|
||||
"notNull": true
|
||||
},
|
||||
"ownerUserId": {
|
||||
"type": "refUser",
|
||||
"length": 255,
|
||||
"notNull": true
|
||||
},
|
||||
"persistent": {
|
||||
"type": "boolean",
|
||||
"notNull": true,
|
||||
"defaultValue": false
|
||||
},
|
||||
"presenterUserId": {
|
||||
"type": "varchar",
|
||||
"length": 255
|
||||
},
|
||||
"stageProtocol": {
|
||||
"type": "text"
|
||||
},
|
||||
"stageHostId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"stageShareId": {
|
||||
"type": "varchar",
|
||||
"length": 255
|
||||
},
|
||||
"guestLinkToken": {
|
||||
"type": "varchar",
|
||||
"length": 255
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "timestamp",
|
||||
"notNull": true,
|
||||
"defaultNow": true
|
||||
},
|
||||
"endedAt": {
|
||||
"type": "text"
|
||||
}
|
||||
},
|
||||
"indexes": [
|
||||
{
|
||||
"name": "idx_collab_rooms_guest_token",
|
||||
"columns": ["guestLinkToken"],
|
||||
"unique": true
|
||||
},
|
||||
{
|
||||
"name": "idx_collab_rooms_owner",
|
||||
"columns": ["ownerUserId"]
|
||||
}
|
||||
],
|
||||
"adopts": "collab_rooms"
|
||||
},
|
||||
"room_members": {
|
||||
"columns": {
|
||||
"id": {
|
||||
"type": "id",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"roomId": {
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"notNull": true
|
||||
},
|
||||
"userId": {
|
||||
"type": "refUser",
|
||||
"length": 255,
|
||||
"notNull": true
|
||||
},
|
||||
"roomRole": {
|
||||
"type": "text",
|
||||
"notNull": true,
|
||||
"defaultValue": "member"
|
||||
},
|
||||
"addedBy": {
|
||||
"type": "varchar",
|
||||
"length": 255
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "timestamp",
|
||||
"notNull": true,
|
||||
"defaultNow": true
|
||||
}
|
||||
},
|
||||
"indexes": [
|
||||
{
|
||||
"name": "idx_collab_room_members_room_user",
|
||||
"columns": ["roomId", "userId"],
|
||||
"unique": true
|
||||
},
|
||||
{
|
||||
"name": "idx_collab_room_members_user",
|
||||
"columns": ["userId"]
|
||||
}
|
||||
],
|
||||
"adopts": "collab_room_members"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
-- 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" text PRIMARY KEY NOT NULL,
|
||||
"host_id" integer NOT NULL,
|
||||
"owner_user_id" text NOT NULL,
|
||||
"protocol" text NOT NULL,
|
||||
"session_id" text NOT NULL,
|
||||
"tab_instance_id" text,
|
||||
"share_type" text NOT NULL,
|
||||
"target_user_id" text,
|
||||
"link_token" text 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" integer PRIMARY KEY AUTOINCREMENT,
|
||||
"share_id" text NOT NULL,
|
||||
"user_id" text,
|
||||
"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" text PRIMARY KEY NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"owner_user_id" text NOT NULL,
|
||||
"persistent" integer NOT NULL DEFAULT 0,
|
||||
"presenter_user_id" text,
|
||||
"stage_protocol" text,
|
||||
"stage_host_id" integer,
|
||||
"stage_share_id" text,
|
||||
"guest_link_token" text,
|
||||
"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" integer PRIMARY KEY AUTOINCREMENT,
|
||||
"room_id" text NOT NULL,
|
||||
"user_id" text NOT NULL,
|
||||
"room_role" text NOT NULL DEFAULT 'member',
|
||||
"added_by" text,
|
||||
"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";
|
||||
Reference in new issue
Block a user