DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

027503b8f813bfcfbc9546b4255790a1b18d8ead — Jonni Liljamo 1 year, 10 months ago 4e3f0c9
feat(api): migration create_games
A api/migrations/2023-02-17-095727_create_games/down.sql => api/migrations/2023-02-17-095727_create_games/down.sql +3 -0
@@ 0,0 1,3 @@
-- This file should undo anything in `up.sql`

DROP TABLE games;

A api/migrations/2023-02-17-095727_create_games/up.sql => api/migrations/2023-02-17-095727_create_games/up.sql +14 -0
@@ 0,0 1,14 @@
-- Your SQL goes here

CREATE TABLE games (
    id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
    created_at TIMESTAMPTZ NOT NULL DEFAULT current_timestamp,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT current_timestamp,
    host_id uuid REFERENCES users(id) NOT NULL,
    guest_id uuid REFERENCES users(id) DEFAULT NULL,
    state SMALLINT NOT NULL,
    ended_at TIMESTAMPTZ DEFAULT NULL,
    game_data_id uuid REFERENCES gamedata(id) NOT NULL
);

SELECT diesel_manage_updated_at('games');

M api/src/schema.rs => api/src/schema.rs +15 -0
@@ 26,6 26,19 @@ diesel::table! {
}

diesel::table! {
    games (id) {
        id -> Uuid,
        created_at -> Timestamptz,
        updated_at -> Timestamptz,
        host_id -> Uuid,
        guest_id -> Nullable<Uuid>,
        state -> Int2,
        ended_at -> Nullable<Timestamptz>,
        game_data_id -> Uuid,
    }
}

diesel::table! {
    users (id) {
        id -> Uuid,
        created_at -> Timestamp,


@@ 38,9 51,11 @@ diesel::table! {

diesel::joinable!(actions -> gamedata (game_data_id));
diesel::joinable!(actions -> users (invoker));
diesel::joinable!(games -> gamedata (game_data_id));

diesel::allow_tables_to_appear_in_same_query!(
    actions,
    gamedata,
    games,
    users,
);