create table users (
    id              uuid        primary key,
    login           text        not null
);

create type status as enum ('active', 'offline', 'busy');

create table stations (
    id              uuid        primary key,
    slug            text        not null,
    status          status      not null
);

create table satellites (
    id              uuid        primary key,
    display_name    text        not null,
    status          status      not null
);

create table subscriptions (
    id              uuid        primary key,
    user_id         uuid        not null references users(id),
    station_id      uuid        null references satellites(id),
    satellite_id    uuid        null references stations(id),
    created_at      timestamp   not null,
    updated_at      timestamp   not null,

    check (station_id is not null or satellite_id is not null)
);