table! {
    controllers (id) {
        id -> Integer,
        uid -> Text,
        name -> Text,
        ip -> Nullable<Text>,
        port -> Nullable<Integer>,
        relay_count -> Nullable<Integer>,
        active -> Bool,
    }
}

table! {
    junction_relay_schedule (id) {
        id -> Integer,
        weekday -> SmallInt,
        relay_id -> Nullable<Integer>,
        schedule_id -> Nullable<Integer>,
    }
}

table! {
    junction_tag (id) {
        id -> Integer,
        tag_id -> Integer,
        relay_id -> Nullable<Integer>,
        schedule_id -> Nullable<Integer>,
    }
}

table! {
    macro_actions (id) {
        id -> Integer,
        macro_id -> Integer,
        relay_id -> Integer,
        schedule_id -> Integer,
        weekday -> SmallInt,
    }
}

table! {
    macros (id) {
        id -> Integer,
        uid -> Text,
        name -> Text,
    }
}

table! {
    relays (id) {
        id -> Integer,
        name -> Text,
        number -> Integer,
        controller_id -> Integer,
    }
}

table! {
    schedules (id) {
        id -> Integer,
        uid -> Binary,
        name -> Text,
        periods -> Binary,
    }
}

table! {
    tags (id) {
        id -> Integer,
        tag -> Text,
    }
}

joinable!(junction_relay_schedule -> relays (relay_id));
joinable!(junction_relay_schedule -> schedules (schedule_id));
joinable!(junction_tag -> relays (relay_id));
joinable!(junction_tag -> schedules (schedule_id));
joinable!(junction_tag -> tags (tag_id));
joinable!(macro_actions -> macros (macro_id));
joinable!(macro_actions -> relays (relay_id));
joinable!(macro_actions -> schedules (schedule_id));
joinable!(relays -> controllers (controller_id));

allow_tables_to_appear_in_same_query!(
    controllers,
    junction_relay_schedule,
    junction_tag,
    macro_actions,
    macros,
    relays,
    schedules,
    tags,
);