1
0
mirror of git://f0xx.org/ac/ac-deploy synced 2026-07-29 01:37:54 +03:00

deploy: fix load-schemas paths; add 080_sfu_rooms migration

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-06-28 22:41:22 +02:00
parent 386f7ab793
commit 9edcd44689
2 changed files with 60 additions and 4 deletions

View File

@@ -0,0 +1,38 @@
-- SFU room management schema — MariaDB / SQLite default
-- Created: 2026-06-28
CREATE TABLE IF NOT EXISTS sfu_rooms (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
janus_room_id INT NOT NULL UNIQUE,
owner_id BIGINT UNSIGNED NOT NULL,
name VARCHAR(128) NOT NULL DEFAULT '',
purpose VARCHAR(32) NOT NULL DEFAULT 'screen_cast',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
closed_at DATETIME NULL,
INDEX idx_sfu_rooms_owner (owner_id),
INDEX idx_sfu_rooms_closed (closed_at)
);
CREATE TABLE IF NOT EXISTS sfu_participants (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
room_id BIGINT UNSIGNED NOT NULL,
user_id BIGINT UNSIGNED NOT NULL,
janus_handle_id BIGINT UNSIGNED NOT NULL,
role VARCHAR(16) NOT NULL DEFAULT 'publisher',
joined_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
left_at DATETIME NULL,
INDEX idx_sfup_room (room_id),
INDEX idx_sfup_user (user_id),
INDEX idx_sfup_joined (joined_at)
);
CREATE TABLE IF NOT EXISTS sfu_stats (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
participant_id BIGINT UNSIGNED NOT NULL,
bitrate_kbps DECIMAL(10,2) NOT NULL DEFAULT 0,
packet_loss DECIMAL(5,2) NOT NULL DEFAULT 0,
sampled_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX idx_sfustat_participant (participant_id),
INDEX idx_sfustat_time (sampled_at)
);

View File

@@ -1,7 +1,18 @@
#!/bin/sh
# Load project schemas on cast01 primary only.
set -eu
SHARED=/shared/cluster/sql
# Lab-seeds SQL is under lab-seeds/backend/sql; fall back to legacy sql/ layout.
if [ -f /shared/cluster/lab-seeds/backend/sql/schema.mariadb.sql ]; then
SQL_BASE=/shared/cluster/lab-seeds/backend/sql
SQL_CRASHES="$SQL_BASE"
SQL_CRASHES_MIGRATIONS="$SQL_BASE/migrations"
SQL_URL_SHORTENER="$SQL_BASE"
else
SQL_BASE=/shared/cluster/sql
SQL_CRASHES="$SQL_BASE/crashes"
SQL_CRASHES_MIGRATIONS="$SQL_BASE/crashes/migrations"
SQL_URL_SHORTENER="$SQL_BASE/url_shortener"
fi
[ "$(hostname -s)" = cast01 ] || { echo "run on cast01 only"; exit 1; }
apply() {
@@ -14,11 +25,12 @@ apply() {
apply_db() {
db="$1"
f="$2"
[ -f "$f" ] || { echo "skip (missing): $f"; return 0; }
echo "==> $db < $f"
mariadb -u root "$db" < "$f"
}
apply "$SHARED/crashes/schema.mariadb.sql"
apply "$SQL_CRASHES/schema.mariadb.sql"
# Migrations after base schema (003 is for legacy; base schema already includes tickets)
for m in \
@@ -30,10 +42,16 @@ for m in \
008_auth_email_2fa.sql \
009_rssh_sessions.sql
do
apply_db androidcast_crashes "$SHARED/crashes/migrations/$m"
apply_db androidcast_crashes "$SQL_CRASHES_MIGRATIONS/$m"
done
apply "$SHARED/url_shortener/schema.mariadb.sql"
# Apply SFU rooms schema if present
apply_db androidcast_crashes "$SQL_CRASHES_MIGRATIONS/080_sfu_rooms.sql" 2>/dev/null || true
if [ -f "$SQL_URL_SHORTENER/schema.mariadb.sql" ] && \
[ "$SQL_URL_SHORTENER/schema.mariadb.sql" != "$SQL_CRASHES/schema.mariadb.sql" ]; then
apply "$SQL_URL_SHORTENER/schema.mariadb.sql"
fi
mariadb -u root -e "SHOW DATABASES; SELECT COUNT(*) AS crash_tables FROM information_schema.tables WHERE table_schema='androidcast_crashes'; SELECT COUNT(*) AS url_tables FROM information_schema.tables WHERE table_schema='url_shortener';"
echo "schemas_loaded_ok"