import dev.sasikanth.rss.reader.core.model.local.ServiceType;

CREATE TABLE user(
    id TEXT NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    email TEXT NOT NULL,
    avatarUrl TEXT,
    token TEXT NOT NULL,
    refreshToken TEXT NOT NULL,
    serverUrl TEXT,
    lastSyncStatus TEXT NOT NULL DEFAULT 'IDLE',
    serviceType TEXT AS ServiceType DEFAULT NULL
);

insert:
INSERT OR REPLACE INTO user(id, name, email, avatarUrl, token, refreshToken, serverUrl, lastSyncStatus, serviceType)
VALUES (:id, :name, :email, :avatarUrl, :token, :refreshToken, :serverUrl, :lastSyncStatus, :serviceType);

delete:
DELETE FROM user;

user:
SELECT * FROM user LIMIT 1;

updateLastSyncStatus:
UPDATE user SET lastSyncStatus = :lastSyncStatus;

updateToken:
UPDATE user SET token = :token;

updateRefreshToken:
UPDATE user SET refreshToken = :refreshToken;
