code.vegaprotocol.io/vega@v0.79.0/datanode/sqlstore/migrations/0034_teams.sql (about)

     1  -- +goose Up
     2  
     3  create table if not exists teams
     4  (
     5      id               bytea                    not null,
     6      referrer         bytea                    not null, -- ID of the party that created the team
     7      name             varchar                  not null,
     8      team_url         varchar,
     9      avatar_url       varchar,
    10      closed           BOOLEAN                  NOT NULL DEFAULT FALSE,
    11      created_at_epoch bigint                   not null,
    12      created_at       timestamp with time zone not null,
    13      vega_time        timestamp with time zone not null,
    14      primary key (id)
    15  );
    16  
    17  create table if not exists team_members
    18  (
    19      team_id         bytea                    not null references teams (id),
    20      party_id        bytea                    not null, -- ID of the party that joined the team
    21      joined_at_epoch bigint                   not null,
    22      joined_at       timestamp with time zone not null,
    23      vega_time       timestamp with time zone not null,
    24      primary key (team_id, party_id, joined_at_epoch)
    25  );
    26  
    27  create view current_team_members as
    28  select distinct on (party_id) *
    29  from team_members
    30  order by party_id, joined_at_epoch desc;
    31  
    32  -- +goose Down
    33  
    34  drop view if exists team_members_history;
    35  drop view if exists current_team_members;
    36  drop table if exists team_members;
    37  drop table if exists teams;