Commit 132f4d17 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Increase schema column size limits. Merge #114

parent 6f478bd4
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -8,10 +8,20 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
- New code runtime function to list leaderboard records for a given set of users.
- New code runtime function to list leaderboard records around a given user.
- New code runtime function to execute raw SQL queries.
- New code runtime function to run CRON expressions.

### Changed
- Handle update now returns a bad input error code if handle is too long.
- Improved handling of content type request headers in HTTP runtime script invocations.
- Increase default maximum length of user handle from 20 to 128 characters.
- Increase default maximum length of device and custom IDs from 64 to 128 characters.
- Increase default maximum length of various name, location, timezone, and other free text fields to 255 characters.
- Increase default maximum length of storage bucket, collection, and record from 70 to 128 characters.
- Increase default maximum length of topic room names from 64 to 128 characters.

### Fixed
- Realtime notification routing now correctly resolves connected users.
- The server will now correctly log a reason when clients disconnect unexpectedly.

## [1.0.1] - 2017-08-05
### Added
+33 −33
Original line number Diff line number Diff line
@@ -18,22 +18,22 @@
CREATE TABLE IF NOT EXISTS users (
    PRIMARY KEY (id),
    id             BYTEA         NOT NULL,
    handle         VARCHAR(20)   CONSTRAINT users_handle_key UNIQUE NOT NULL,
    fullname       VARCHAR(70),
    handle         VARCHAR(128)  CONSTRAINT users_handle_key UNIQUE NOT NULL,
    fullname       VARCHAR(255),
    avatar_url     VARCHAR(255),
    -- https://tools.ietf.org/html/bcp47
    lang           VARCHAR(18)   DEFAULT 'en' NOT NULL,
    location       VARCHAR(64),  -- e.g. "San Francisco, CA"
    timezone       VARCHAR(64),  -- e.g. "Pacific Time (US & Canada)"
    location       VARCHAR(255), -- e.g. "San Francisco, CA"
    timezone       VARCHAR(255), -- e.g. "Pacific Time (US & Canada)"
    utc_offset_ms  SMALLINT      DEFAULT 0 NOT NULL,
    metadata       BYTEA         DEFAULT '{}' CHECK (length(metadata) < 16000) NOT NULL,
    email          VARCHAR(255)  UNIQUE,
    password       BYTEA         CHECK (length(password) < 32000),
    facebook_id    VARCHAR(64)   UNIQUE,
    google_id      VARCHAR(64)   UNIQUE,
    gamecenter_id  VARCHAR(64)   UNIQUE,
    steam_id       VARCHAR(64)   UNIQUE,
    custom_id      VARCHAR(64)   UNIQUE,
    facebook_id    VARCHAR(128)  UNIQUE,
    google_id      VARCHAR(128)  UNIQUE,
    gamecenter_id  VARCHAR(128)  UNIQUE,
    steam_id       VARCHAR(128)  UNIQUE,
    custom_id      VARCHAR(128)  UNIQUE,
    created_at     BIGINT        CHECK (created_at > 0) NOT NULL,
    updated_at     BIGINT        CHECK (updated_at > 0) NOT NULL,
    verified_at    BIGINT        CHECK (verified_at >= 0) DEFAULT 0 NOT NULL,
@@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS users (
CREATE TABLE IF NOT EXISTS user_device (
    PRIMARY KEY (id),
    FOREIGN KEY (user_id) REFERENCES users(id),
    id      VARCHAR(64) NOT NULL,
    id      VARCHAR(128) NOT NULL,
    user_id BYTEA        NOT NULL
);
-- In cockroachdb a FK relationship will implicitly create an index on the
@@ -77,7 +77,7 @@ CREATE TABLE IF NOT EXISTS groups (
    PRIMARY KEY (id),
    id            BYTEA         NOT NULL,
    creator_id    BYTEA         NOT NULL,
    name          VARCHAR(70)   CONSTRAINT groups_name_key UNIQUE NOT NULL,
    name          VARCHAR(255)  CONSTRAINT groups_name_key UNIQUE NOT NULL,
    description   VARCHAR(255),
    avatar_url    VARCHAR(255),
    -- https://tools.ietf.org/html/bcp47
@@ -111,13 +111,13 @@ CREATE INDEX IF NOT EXISTS source_id_destination_id_state_idx ON group_edge (sou

CREATE TABLE IF NOT EXISTS message (
    PRIMARY KEY (topic, topic_type, message_id),
    topic      BYTEA       CHECK (length(topic) <= 64) NOT NULL,
    topic      BYTEA        CHECK (length(topic) <= 128) NOT NULL,
    topic_type SMALLINT     NOT NULL, -- dm(0), room(1), group(2)
    message_id BYTEA        NOT NULL,
    user_id    BYTEA        NOT NULL,
    created_at BIGINT       CHECK (created_at > 0) NOT NULL,
    expires_at BIGINT       DEFAULT 0 CHECK (created_at >= 0) NOT NULL,
    handle     VARCHAR(20) NOT NULL,
    handle     VARCHAR(128) NOT NULL,
    type       SMALLINT     NOT NULL, -- chat(0), group_join(1), group_add(2), group_leave(3), group_kick(4), group_promoted(5)
    -- FIXME replace with JSONB
    data       BYTEA        DEFAULT '{}' CHECK (length(data) <= 1000) NOT NULL
@@ -129,9 +129,9 @@ CREATE TABLE IF NOT EXISTS storage (
    PRIMARY KEY (bucket, collection, user_id, record, deleted_at),
    id         BYTEA        NOT NULL,
    user_id    BYTEA,
    bucket     VARCHAR(70) NOT NULL,
    collection VARCHAR(70) NOT NULL,
    record     VARCHAR(70) NOT NULL,
    bucket     VARCHAR(128) NOT NULL,
    collection VARCHAR(128) NOT NULL,
    record     VARCHAR(128) NOT NULL,
    -- FIXME replace with JSONB
    value      BYTEA        DEFAULT '{}' CHECK (length(value) < 16000) NOT NULL,
    version    BYTEA        NOT NULL,
+16 −16
Original line number Diff line number Diff line
@@ -38,22 +38,22 @@ CREATE TABLE IF NOT EXISTS leaderboard_record (
    id                 BYTEA         UNIQUE NOT NULL,
    leaderboard_id     BYTEA         NOT NULL,
    owner_id           BYTEA         NOT NULL,
    handle             VARCHAR(20)  NOT NULL,
    handle             VARCHAR(128)  NOT NULL,
    lang               VARCHAR(18)   DEFAULT 'en' NOT NULL,
    location           VARCHAR(64), -- e.g. "San Francisco, CA"
    timezone           VARCHAR(64), -- e.g. "Pacific Time (US & Canada)"
    location           VARCHAR(255), -- e.g. "San Francisco, CA"
    timezone           VARCHAR(255), -- e.g. "Pacific Time (US & Canada)"
    rank_value         BIGINT        DEFAULT 0 CHECK (rank_value >= 0) NOT NULL,
    score              BIGINT        DEFAULT 0 NOT NULL,
    num_score          INT           DEFAULT 0 CHECK (num_score >= 0) NOT NULL,
    -- FIXME replace with JSONB
    metadata           BYTEA         DEFAULT '{}' CHECK (length(metadata) < 16000) NOT NULL,
    ranked_at          INT          CHECK (ranked_at >= 0) DEFAULT 0 NOT NULL,
    updated_at         INT          CHECK (updated_at > 0) NOT NULL,
    ranked_at          BIGINT        CHECK (ranked_at >= 0) DEFAULT 0 NOT NULL,
    updated_at         BIGINT        CHECK (updated_at > 0) NOT NULL,
    -- Used to enable proper order in revscan when sorting by score descending.
    -- Revscan is unaviodable here due to cockroachdb/cockroach#14241.
    updated_at_inverse INT          CHECK (updated_at > 0) NOT NULL,
    expires_at         INT          CHECK (expires_at >= 0) DEFAULT 0 NOT NULL,
    banned_at          INT          CHECK (expires_at >= 0) DEFAULT 0 NOT NULL
    updated_at_inverse BIGINT        CHECK (updated_at > 0) NOT NULL,
    expires_at         BIGINT        CHECK (expires_at >= 0) DEFAULT 0 NOT NULL,
    banned_at          BIGINT        CHECK (expires_at >= 0) DEFAULT 0 NOT NULL
);
CREATE INDEX IF NOT EXISTS owner_id_leaderboard_id_idx ON leaderboard_record (owner_id, leaderboard_id);
CREATE INDEX IF NOT EXISTS leaderboard_id_expires_at_score_updated_at_inverse_id_idx ON leaderboard_record (leaderboard_id, expires_at, score, updated_at_inverse, id);
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ func (n *NotificationService) NotificationSend(notifications []*NNotification) e
	}

	for userID, ns := range notificationsByUser {
		presences := n.tracker.ListByTopicUser("notification", userID)
		presences := n.tracker.ListByTopicUser("notifications", userID)
		if len(presences) != 0 {
			nots := convertNotifications(ns)
			n.messageRouter.Send(n.logger, presences, nots)
+2 −2
Original line number Diff line number Diff line
@@ -66,9 +66,9 @@ func SelfUpdate(logger *zap.Logger, db *sql.DB, updates []*SelfUpdateOp) (Error_
		statements := make([]string, 0)
		params := make([]interface{}, 0)
		if update.Handle != "" {
			if len(update.Handle) > 20 {
			if len(update.Handle) > 128 {
				code = BAD_INPUT
				err = errors.New("Handle must be 1-20 characters long")
				err = errors.New("Handle must be 1-128 characters long")
				return code, err
			}
			statements = append(statements, "handle = $"+strconv.Itoa(index))
Loading