-- Migration 031: Remove redundant username/password from peertube_settings.
-- PeerTube now shares SMTP credentials. Also removes oauth_client_id/secret
-- since those are fetched on-demand from the PeerTube API.

-- SQLite doesn't support DROP COLUMN natively in older versions.
-- We rebuild the table without the dropped columns.

CREATE TABLE peertube_settings_new (
    id                   INTEGER PRIMARY KEY CHECK (id = 1),
    instance_url         TEXT    NOT NULL DEFAULT '',
    channel_id           INTEGER NOT NULL DEFAULT 1,
    privacy              INTEGER NOT NULL DEFAULT 1,
    peertube_video_label TEXT    NOT NULL DEFAULT '',
    peertube_audio_label TEXT    NOT NULL DEFAULT '',
    updated_at           TEXT    NOT NULL DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO peertube_settings_new (id, instance_url, channel_id, privacy, peertube_video_label, peertube_audio_label, updated_at)
SELECT id, instance_url, channel_id, privacy, peertube_video_label, peertube_audio_label, updated_at
FROM peertube_settings;

DROP TABLE peertube_settings;
ALTER TABLE peertube_settings_new RENAME TO peertube_settings;
