Files
rustpad/migrations/postgres/0022_user_editor_preferences.sql
T

24 lines
1.1 KiB
SQL

CREATE TABLE user_editor_preferences (
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
pad_id BIGINT REFERENCES pads(id) ON DELETE CASCADE,
note_id BIGINT REFERENCES notes(id) ON DELETE CASCADE,
authorship_mode TEXT NOT NULL DEFAULT 'simple',
colors_enabled BOOLEAN NOT NULL DEFAULT TRUE,
compact_view BOOLEAN NOT NULL DEFAULT TRUE,
editor_line_numbers BOOLEAN NOT NULL DEFAULT TRUE,
preview_line_numbers BOOLEAN NOT NULL DEFAULT FALSE,
line_links BOOLEAN NOT NULL DEFAULT FALSE,
font_family TEXT NOT NULL DEFAULT 'mono',
font_size BIGINT NOT NULL DEFAULT 14,
updated_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP::text),
CHECK ((pad_id IS NOT NULL AND note_id IS NULL) OR (pad_id IS NULL AND note_id IS NOT NULL)),
UNIQUE (user_id, pad_id),
UNIQUE (user_id, note_id)
);
CREATE INDEX idx_user_editor_preferences_user ON user_editor_preferences(user_id);
CREATE INDEX idx_user_editor_preferences_pad ON user_editor_preferences(pad_id);
CREATE INDEX idx_user_editor_preferences_note ON user_editor_preferences(note_id);
DROP TABLE resource_editor_settings;