Fix problems with SQL queries & depreciation function parsing.

[?]
Jun 14, 2015, 3:07 AM
ZITLSTYXUOESFELOW3DLBKWKMSS5ZJYCTKMK4Z44WGIYAKYSMMVAC

Dependencies

  • [2] QMRKFEPG Refactor QDB to use a free monad algebra instead.
  • [3] EQXRXRZD Changed to use tasty instead of test-framework
  • [4] NVOCQVAS Initial failing tests.
  • [5] Z7KS5XHH Very WIP. Wow.
  • [6] GCVQD44V Create amends endpoint, switch to UUID primary keys
  • [7] RLDPSLKK Added sqlite database creation scripts.
  • [8] 4U7F3CPI THE GREAT RENAMING OF THINGS!
  • [9] E2KOBKIJ Add setup script detailing the setup of the docker host.
  • [10] O5FVTOM6 Undo JSON silliness, enable a couple more routes.
  • [*] IZEVQF62 Work in progress replacing sqlite with postgres.

Change contents

  • replacement in lib/Aftok/Database/PostgreSQL.hs at line 256
    [2.4924][2.4924:5009]()
    "SELECT project_name, inception_date, initiator_id FROM projects WHERE id = ?"
    [2.4924]
    [2.5009]
    "SELECT project_name, inception_date, initiator_id, depreciation_fn FROM projects WHERE id = ?"
  • replacement in lib/Aftok/Database/PostgreSQL.hs at line 262
    [2.5127][2.5127:5448]()
    "SELECT p.id, p.project_name, p.inception_date, p.initiator_id \
    \FROM projects p JOIN project_companions pc ON pc.project_id = p.id \
    \WHERE pc.user_id = ? \
    \UNION \
    \SELECT p.id, p.project_name, p.inception_date, p.initiator_id \
    \FROM projects p \
    \WHERE p.initiator_id = ?"
    [2.5127]
    [2.5448]
    "SELECT p.id, p.project_name, p.inception_date, p.initiator_id, p.depreciation_fn \
    \FROM projects p LEFT OUTER JOIN project_companions pc ON pc.project_id = p.id \
    \WHERE pc.user_id = ? \
    \OR p.initiator_id = ?"
  • replacement in lib/Aftok.hs at line 82
    [2.11318][2.11318:11354]()
    t <- v .: "text" :: Parser Text
    [2.11318]
    [2.11354]
    t <- v .: "type" :: Parser Text
  • file deletion: quixotic-sqlite.sql (----------)aftok-sqlite.sql (----------)
    [3.1369][3.352:395](),[3.395][3.43:43](),[3.1369][3.3420:3460](),[3.3460][3.43:43]()
    CREATE TABLE work_events (btc_addr TEXT, event_type TEXT, event_time INTEGER);
    CREATE TABLE auctions (raise_amount INTEGER, end_time INTEGER);
    CREATE TABLE bids (auction_id INTEGER, user_id INTEGER, bid_seconds INTEGER, bid_amount INTEGER, bid_time INTEGER);
    create table users (btc_addr TEXT, email TEXT);
  • file move: aftok-pg.sql (----------)aftok-pg-001.sql (----------)
    [3.1369]
    [3.3144]
  • file addition: aftok-pg-002.sql (----------)
    [3.1369]
    alter table projects add depreciation_fn json not null default '{"type": "LinearDepreciation", "arguments": {"undep": 6, "dep": 60}}';
    alter table project_companions add invited_by uuid references users(id);
    update project_companions set invited_by = user_id; --
    alter table project_companions alter column invited_by set not null;