fix(postgres): use INT instead of BIGINT for simple counts

This commit is contained in:
trisua 2025-04-03 15:56:44 -04:00
parent 27d7c2f4b5
commit 9f4e8a4d25
13 changed files with 55 additions and 56 deletions

View file

@ -35,18 +35,17 @@ impl DataManager {
/// Create a new [`DataManager`] (and init database).
pub async fn new(config: Config) -> Result<Self> {
let manager = PostgresConnectionManager::new(
PgConfig::from_str(&format!(
"postgresql://{}:{}@{}/{}?target_session_attrs=read-write",
config.database.user,
config.database.password,
config.database.url,
config.database.name
))
.unwrap(),
NoTls,
let con_url = &format!(
"postgresql://{}:{}@{}/{}?target_session_attrs=read-write",
config.database.user,
config.database.password,
config.database.url,
config.database.name
);
println!("attempting connection on: {con_url}");
let manager = PostgresConnectionManager::new(PgConfig::from_str(con_url).unwrap(), NoTls);
let pool = Pool::builder().max_size(15).build(manager).await.unwrap();
Ok(Self(
config.clone(),

View file

@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS communities (
write_access TEXT NOT NULL,
join_access TEXT NOT NULL,
-- likes
likes BIGINT NOT NULL,
dislikes BIGINT NOT NULL,
likes INT NOT NULL,
dislikes INT NOT NULL,
-- counts
member_count BIGINT NOT NULL
member_count INT NOT NULL
)

View file

@ -3,5 +3,5 @@ CREATE TABLE IF NOT EXISTS memberships (
created BIGINT NOT NULL,
owner BIGINT NOT NULL,
community BIGINT NOT NULL,
role BIGINT NOT NULL
role INT NOT NULL
)

View file

@ -4,5 +4,5 @@ CREATE TABLE IF NOT EXISTS notifications (
title TEXT NOT NULL,
content TEXT NOT NULL,
owner BIGINT NOT NULL,
read BIGINT NOT NULL
read INT NOT NULL
)

View file

@ -5,10 +5,10 @@ CREATE TABLE IF NOT EXISTS posts (
owner BIGINT NOT NULL,
community BIGINT NOT NULL,
context TEXT NOT NULL,
replying_to BIGINT, -- the ID of the post this is a comment on... NULL means it isn't a reply
replying_to BIGINT, -- the ID of the post this is a comment on... 0 means it isn't a reply
-- likes
likes BIGINT NOT NULL,
dislikes BIGINT NOT NULL,
likes INT NOT NULL,
dislikes INT NOT NULL,
-- other counts
comment_count BIGINT NOT NULL
comment_count INT NOT NULL
)

View file

@ -4,5 +4,5 @@ CREATE TABLE IF NOT EXISTS reactions (
owner BIGINT NOT NULL,
asset BIGINT NOT NULL,
asset_type TEXT NOT NULL,
is_like BIGINT NOT NULL
is_like INT NOT NULL
)

View file

@ -6,10 +6,10 @@ CREATE TABLE IF NOT EXISTS users (
salt TEXT NOT NULL,
settings TEXT NOT NULL,
tokens TEXT NOT NULL,
permissions BIGINT NOT NULL,
verified BIGINT NOT NULL,
notification_count BIGINT NOT NULL,
follower_count BIGINT NOT NULL,
following_count BIGINT NOT NULL,
permissions INT NOT NULL,
verified INT NOT NULL,
notification_count INT NOT NULL,
follower_count INT NOT NULL,
following_count INT NOT NULL,
last_seen BIGINT NOT NULL
)