Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic dice system #119

Merged
merged 6 commits into from
May 3, 2016
Merged

Implement basic dice system #119

merged 6 commits into from
May 3, 2016

Conversation

danneu
Copy link
Owner

@danneu danneu commented May 2, 2016

Schema changes:

-- TODO: campaigns.topic_id NULL
CREATE TABLE campaigns (
  id             serial           PRIMARY KEY,
  user_id        int              NOT NULL REFERENCES users(id),
  title          text             NOT NULL,
  markup         text             NULL,
  html           text             NULL,
  created_at     timestamptz      NOT NULL DEFAULT NOW(),
  roll_count     int              NOT NULL DEFAULT 0,
  last_roll_at   timestamptz      NULL
  --, last_roll_id   int              NULL REFERENCES rolls(id)
);

CREATE TABLE rolls (
  id             serial           PRIMARY KEY,
  user_id        int              NOT NULL REFERENCES users(id),
  campaign_id    int              NOT NULL REFERENCES campaigns(id),
  syntax         text             NOT NULL,
  rolls          json             NOT NULL,
  total          int              NOT NULL,
  note           text             NULL,
  created_at     timestamptz      NOT NULL DEFAULT NOW()
);

-- TWEAKS

ALTER TABLE campaigns ADD COLUMN last_roll_id int NULL REFERENCES rolls(id);

-- INDEXES

-- Looking up all campaigns started by a user
CREATE INDEX campaigns__user_id ON campaigns (user_id);
-- Sorting campaigns by latest roll
CREATE INDEX campaigns__last_roll_id ON campaigns (last_roll_id);
-- Looking up all rows for a campaign
CREATE INDEX rolls__campaign_id ON rolls (campaign_id);

@danneu danneu merged commit f6abb30 into master May 3, 2016
@danneu danneu deleted the dice branch May 3, 2016 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant