Description: (Describe migration here.)
Created: 2016-10-13 05:36:59.592247 UTC
Depends: 
Apply: |
  -- create extension if not exists "uuid-ossp";
    
  create table if not exists users (
    id uuid primary key default uuid_generate_v4(),
    handle text not null,
    btc_addr text not null,
    email text not null  
  );

  create table if not exists projects (
    id uuid primary key default uuid_generate_v4(),
    project_name text not null,
    inception_date timestamp with time zone not null,
    initiator_id uuid references users (id) not null
  );

  create table if not exists project_companions (
    project_id uuid references projects(id) not null,
    user_id uuid references users(id) not null
  );

  create type event_t as enum ('start', 'stop');

  create table if not exists work_events (
    id uuid primary key default uuid_generate_v4(),
    project_id uuid references projects(id) not null,
    user_id uuid references users(id) not null,
    btc_addr text not null,
    event_type event_t not null,
    event_time timestamp with time zone not null,
    event_metadata json not null
  );

  create table if not exists auctions (
    id uuid primary key default uuid_generate_v4(),
    project_id uuid references projects(id) not null,
    initiator_id uuid references users (id) not null,
    raise_amount numeric not null,
    end_time timestamp with time zone not null
  );

  create table if not exists bids (
    id uuid primary key default uuid_generate_v4(),
    auction_id uuid references projects (id) not null,
    bidder_id uuid references users (id) not null,
    bid_seconds integer not null,
    bid_amount numeric not null,
    bid_time timestamp with time zone not null
  );

Revert: |
  drop table bids;
  drop table auctions;
  drop table work_events;
  drop table project_companions;
  drop table projects;
  drop table users;