Skip to content

Commit

Permalink
Remove in-database text limits
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Jan 30, 2022
1 parent 01a0dd2 commit 540fa17
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 43 deletions.
26 changes: 13 additions & 13 deletions crates/schema/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ thorn::tables! {
Dob: Type::DATE,
Flags: Type::INT4,
Discriminator: UINT2,
Username: Type::VARCHAR,
Username: Type::TEXT,
Email: Type::TEXT,
Passhash: Type::TEXT,
CustomStatus: Type::VARCHAR,
Biography: Type::VARCHAR,
CustomStatus: Type::TEXT,
Biography: Type::TEXT,
Preferences: Type::JSONB,
MfaSecret: Type::BYTEA,
MfaBackup: Type::BYTEA,
}

pub struct UserFreelist in Lantern {
Username: Type::VARCHAR,
Username: Type::TEXT,
Discriminator: UINT2,
}

Expand Down Expand Up @@ -106,8 +106,8 @@ thorn::tables! {
UserAId: Users::Id,
UserBId: Users::Id,
Flags: Type::INT2,
NoteA: Type::VARCHAR,
NoteB: Type::VARCHAR
NoteA: Type::TEXT,
NoteB: Type::TEXT
}

pub struct UserBlocks in Lantern {
Expand All @@ -122,7 +122,7 @@ thorn::tables! {
OwnerId: Users::Id,
Flags: Type::INT8,
DeletedAt: Type::TIMESTAMP,
Name: Type::VARCHAR,
Name: Type::TEXT,
Description: Type::TEXT,
}

Expand All @@ -133,8 +133,8 @@ thorn::tables! {
JoinedAt: Type::TIMESTAMP,
Flags: Type::INT2,
Position: Type::INT2,
Nickname: Type::VARCHAR,
CustomStatus: Type::VARCHAR,
Nickname: Type::TEXT,
CustomStatus: Type::TEXT,
}

pub struct Subscriptions in Lantern {
Expand All @@ -153,7 +153,7 @@ thorn::tables! {
Color: Type::INT4,
Position: Type::INT2,
Flags: Type::INT2,
Name: Type::VARCHAR,
Name: Type::TEXT,
}

pub struct RoleMembers in Lantern {
Expand All @@ -167,8 +167,8 @@ thorn::tables! {
FileId: Files::Id,
AspectRatio: Type::FLOAT4,
Flags: Type::INT2,
Name: Type::VARCHAR,
Alt: Type::VARCHAR,
Name: Type::TEXT,
Alt: Type::TEXT,
}

pub struct Reactions in Lantern {
Expand Down Expand Up @@ -196,7 +196,7 @@ thorn::tables! {
Position: Type::INT2,
Flags: Type::INT2,
Name: Type::TEXT,
Topic: Type::VARCHAR,
Topic: Type::TEXT,
}

pub struct Overwrites in Lantern {
Expand Down
8 changes: 4 additions & 4 deletions sql/migrations/000001_create_users/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ CREATE TABLE lantern.users (
-- 2-byte integer that can be displayed as 4 hex digits,
-- actually stored as a 4-byte signed integer because Postgres doesn't support unsigned...
discriminator uint2 NOT NULL,
username varchar(64) NOT NULL,
username text NOT NULL,
email text NOT NULL,
passhash text NOT NULL,
-- custom_status tracks the little blurb that appears on users
custom_status varchar(128),
custom_status text,
-- biography is an extended user description on their profile
biography varchar(4096),
biography text,

-- 2FA Secret key
mfa_secret bytea,
Expand All @@ -39,7 +39,7 @@ CREATE UNIQUE INDEX user_email_idx ON lantern.users


CREATE TABLE lantern.user_freelist (
username varchar(64) NOT NULL,
username text NOT NULL,
discriminator uint2 NOT NULL
);
ALTER TABLE lantern.user_freelist OWNER TO postgres;
Expand Down
12 changes: 6 additions & 6 deletions sql/migrations/000002_create_party/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
--

CREATE TABLE lantern.party (
id bigint NOT NULL,
id bigint NOT NULL,
avatar_id bigint,
owner_id bigint NOT NULL,
owner_id bigint NOT NULL,
-- packed party flags
flags bigint NOT NULL DEFAULT 0,
flags bigint NOT NULL DEFAULT 0,
deleted_at timestamp,
name varchar(256) NOT NULL,
name text NOT NULL,
description text,

CONSTRAINT party_pk PRIMARY KEY (id)
Expand All @@ -36,8 +36,8 @@ CREATE TABLE lantern.party_member (
position smallint NOT NULL DEFAULT 0,

-- same as for user, but per-party
nickname varchar(256),
custom_status varchar(128),
nickname text,
custom_status text,

-- Composite primary key
CONSTRAINT party_member_pk PRIMARY KEY (party_id, user_id)
Expand Down
10 changes: 5 additions & 5 deletions sql/migrations/000003_create_room/up.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CREATE TABLE lantern.rooms (
id bigint NOT NULL,
id bigint NOT NULL,
party_id bigint,
avatar_id bigint,
parent_id bigint,
deleted_at timestamp,
position smallint NOT NULL,
flags smallint NOT NULL DEFAULT 0,
name varchar(128) NOT NULL,
topic varchar(2048),
position smallint NOT NULL,
flags smallint NOT NULL DEFAULT 0,
name text NOT NULL,
topic text,

CONSTRAINT room_pk PRIMARY KEY (id)
);
Expand Down
12 changes: 6 additions & 6 deletions sql/migrations/000007_create_emotes/up.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CREATE TABLE lantern.emotes (
id bigint NOT NULL,
id bigint NOT NULL,
party_id bigint,
file_id bigint NOT NULL,
aspect_ratio real NOT NULL,
flags smallint NOT NULL,
name varchar(64) NOT NULL,
alt varchar(64),
file_id bigint NOT NULL,
aspect_ratio real NOT NULL,
flags smallint NOT NULL,
name text NOT NULL,
alt text,

CONSTRAINT emotes_pk PRIMARY KEY (id)
);
Expand Down
2 changes: 1 addition & 1 deletion sql/migrations/000009_create_roles/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE lantern.roles (
color integer,
position smallint NOT NULL DEFAULT 0,
flags smallint NOT NULL DEFAULT 0,
name varchar(32) NOT NULL,
name text NOT NULL,

CONSTRAINT role_pk PRIMARY KEY (id)
);
Expand Down
4 changes: 2 additions & 2 deletions sql/migrations/000012_register_user/down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DROP PROCEDURE IF EXISTS lantern.register_user(bigint, varchar(64), text, text, date);
DROP PROCEDURE IF EXISTS lantern.update_user(bigint, varchar(64), text, text);
DROP PROCEDURE IF EXISTS lantern.register_user(bigint, text, text, text, date);
DROP PROCEDURE IF EXISTS lantern.update_user(bigint, text, text, text);
4 changes: 2 additions & 2 deletions sql/migrations/000012_register_user/up.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE OR REPLACE PROCEDURE lantern.register_user(
_id bigint,
_username varchar(64),
_username text,
_email text,
_passhash text,
_dob date
Expand Down Expand Up @@ -32,7 +32,7 @@ $$;

CREATE OR REPLACE PROCEDURE lantern.update_user(
_id bigint,
_username varchar(64),
_username text,
_email text,
_passhash text
)
Expand Down
2 changes: 1 addition & 1 deletion sql/migrations/000025_create_friends/down.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DROP VIEW IF EXISTS lantern.agg_friends CACADE:
DROP VIEW IF EXISTS lantern.agg_friends CASCADE;

DROP TABLE IF EXISTS lantern.friendlist CASCADE;
4 changes: 2 additions & 2 deletions sql/migrations/000025_create_friends/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ CREATE TABLE lantern.friendlist (
user_a_id bigint NOT NULL,
user_b_id bigint NOT NULL,
flags smallint NOT NULL DEFAULT 0,
note_a varchar(512),
note_b varchar(512)
note_a text,
note_b text
);
ALTER TABLE lantern.friendlist OWNER TO postgres;

Expand Down
2 changes: 1 addition & 1 deletion sql/migrations/000028_agg_attachments/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SELECT
FROM
lantern.attachments INNER JOIN lantern.files ON files.id = attachments.file_id
WHERE
attachments.flags & 1 = 0 -- where not orphaned
attachments.flags & 1 = 0 IS NOT FALSE -- where not orphaned (flags may be null)
GROUP BY
msg_id
;

0 comments on commit 540fa17

Please sign in to comment.