openvibers/openvibe.chat Commits

emotes.media_url and media_asset_id (Live's Media asset sync), added to existing databases on boot

OP OpenVibers committed 23 Sept 2026 · 55010a5a78 · 2 files, +13 −1


Changes

ddiff --git a/server/db/database.js b/server/db/database.js
iindex 20a2df5..da9c3a4 100644
---- a/server/db/database.js
++++ b/server/db/database.js
@@@ -100,9 +100,19 @@ function close() {
* every change to Chat's tables for the Live mirror — the service does; the importer does not,
* so imported rows (which came from Live) are never sent back.
*/
++const ADDED_COLUMNS = [
++ ['emotes', 'media_url', 'TEXT'], // Live: emote images synced to OpenVibe.Media
++ ['emotes', 'media_asset_id', 'INTEGER'],
++];
++
function initDb({ captureMirror = false } = {}) {
const d = getDb();
d.exec(fs.readFileSync(path.join(__dirname, 'schema.sql'), 'utf8'));
++ // Columns Live added after a Chat database was created (CREATE TABLE IF NOT EXISTS does not add them).
++ for (const [table, column, type] of ADDED_COLUMNS) {
++ const have = d.prepare(`PRAGMA table_info(${table})`).all().some((c) => c.name === column);
++ if (!have) d.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${type}`);
++ }
const upsertAuth = d.prepare('INSERT INTO table_authority (table_name, authority, note) VALUES (?, ?, ?) ON CONFLICT(table_name) DO UPDATE SET authority = excluded.authority, note = excluded.note');
for (const t of Object.keys(CHAT_TABLES)) upsertAuth.run(t, 'chat', 'Chat writes; Live keeps a read mirror');
for (const [t, note] of Object.entries(STAGED_TABLES)) upsertAuth.run(t, 'live', note);
ddiff --git a/server/db/schema.sql b/server/db/schema.sql
iindex 02b0d84..b98a21c 100644
---- a/server/db/schema.sql
++++ b/server/db/schema.sql
@@@ -256,7 +256,9 @@ CREATE TABLE IF NOT EXISTS emotes (
is_approved INTEGER DEFAULT 1,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
channel_owner_id INTEGER,
-- size INTEGER DEFAULT 100
++ size INTEGER DEFAULT 100,
++ media_url TEXT,
++ media_asset_id INTEGER
);
CREATE INDEX IF NOT EXISTS idx_emotes_user ON emotes(user_id);
CREATE INDEX IF NOT EXISTS idx_emotes_channel_owner ON emotes(channel_owner_id);