Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit 292c1cd

Browse files
authored
Merge pull request #39 from polyphony-chat/sqlx-updates
Migration to PostgreSQL and sqlx version upgrade
2 parents 909e29a + 830a05c commit 292c1cd

File tree

100 files changed

+803
-805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+803
-805
lines changed

.rusty-hook.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[hooks]
2-
pre-push = "cargo fmt --all -- --check --color always"
2+
pre-push = "cargo fmt -- --check --color always"
33

44
[logging]
55
verbose = true

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ regex = "1.10.4"
3535
reqwest = "0.12.4"
3636
serde = { version = "1.0.203", features = ["derive"] }
3737
serde_json = { version = "1.0.117", features = ["raw_value"] }
38-
sqlx = { version = "0.7.4", features = [
38+
sqlx = { version = "0.8.0", features = [
3939
"json",
4040
"chrono",
4141
"ipnetwork",
@@ -46,14 +46,13 @@ thiserror = "1.0.61"
4646
tokio = { version = "1.38.0", features = ["full"] }
4747
sentry = "0.33.0"
4848
clap = { version = "4.5.4", features = ["derive"] }
49-
50-
chorus = { git = "http://github.com/polyphony-chat/chorus", rev = "537b025", features = [
49+
chorus = { features = [
5150
"backend",
52-
], default-features = false } # git = "ssh://[email protected]/Quat3rnion/chorus" # path = "../chorus" git = "ssh://[email protected]/polyphony-chat/chorus"
51+
], default-features = false, git = "https://github.com/polyphony-chat/chorus", branch = "dev" } # git = "ssh://[email protected]/Quat3rnion/chorus" # path = "../chorus" git = "ssh://[email protected]/polyphony-chat/chorus"
5352
serde_path_to_error = "0.1.16"
5453
percent-encoding = "2.3.1"
5554
hex = "0.4.3"
5655
itertools = "0.13.0"
57-
56+
sqlx-pg-uint = { version = "0.4.1", features = ["serde"] }
5857
[dev-dependencies]
5958
rusty-hook = "0.11.2"

compose-example.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
MARIADB_USER=symfonia
2-
MARIADB_PASSWORD=symfonia
3-
MARIADB_DATABASE=symfonia
1+
POSTGRES_USER=symfonia
2+
POSTGRES_PASSWORD=symfonia
3+
POSTGRES_DB=symfonia

compose.yaml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
services:
22
db:
33
env_file: .env
4-
image: mariadb
5-
environment:
6-
MARIADB_RANDOM_ROOT_PASSWORD: 1
4+
image: postgres
75
volumes:
8-
- "mariadb:/var/lib/mysql"
6+
- "postgres:/var/lib/postgresql/data"
7+
environment:
8+
- PGDATA=/var/lib/postgresql/data/pgdata
99
healthcheck:
10-
test:
11-
[
12-
"CMD",
13-
"healthcheck.sh",
14-
"--connect",
15-
"--innodb_initialized"
16-
]
17-
start_period: 10s
18-
interval: 10s
19-
timeout: 5s
20-
retries: 3
10+
test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}"]
11+
interval: 3s
12+
timeout: 3s
13+
retries: 10
2114
app:
2215
env_file: .env
2316
build: .
2417
environment:
2518
- DATABASE_URL=db
26-
- DATABASE_USERNAME=${MARIADB_USER}
27-
- DATABASE_PASSWORD=${MARIADB_PASSWORD}
28-
- DATABASE_NAME=${MARIADB_DATABASE}
19+
- DATABASE_USERNAME=${POSTGRES_USER}
20+
- DATABASE_PASSWORD=${POSTGRES_PASSWORD}
21+
- DATABASE_NAME=${POSTGRES_DB}
2922
depends_on:
3023
db:
3124
condition: service_healthy
@@ -36,4 +29,4 @@ services:
3629
- 3003:3003/udp
3730

3831
volumes:
39-
mariadb:
32+
postgres:

migrations/20231007011602_categories.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ create table if not exists categories
44
primary key,
55
name varchar(255) null,
66
localizations text not null,
7-
is_primary tinyint null
7+
is_primary smallint null
88
);

migrations/20231007011617_client_release.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ create table if not exists client_release
33
id varchar(255) not null
44
primary key,
55
name varchar(255) not null,
6-
pub_date datetime not null,
6+
pub_date timestamp not null,
77
url varchar(255) not null,
88
platform varchar(255) not null,
9-
enabled tinyint not null,
9+
enabled smallint not null,
1010
notes varchar(255) null
1111
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
create table if not exists config
22
(
3-
`key` varchar(255) not null
3+
key varchar(255) not null
44
primary key,
5-
value text null
5+
value json null
66
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
create table if not exists connection_config
22
(
3-
`key` varchar(255) not null
3+
key varchar(255) not null
44
primary key,
55
value text null
66
);

migrations/20231007011719_rate_limits.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ create table if not exists rate_limits
44
primary key,
55
executor_id varchar(255) not null,
66
hits int not null,
7-
blocked tinyint not null,
8-
expires_at datetime not null
7+
blocked smallint not null,
8+
expires_at timestamp not null
99
);
Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1-
create table if not exists user_settings
1+
CREATE SEQUENCE user_settings_index_seq;
2+
3+
CREATE TABLE IF NOT EXISTS user_settings
24
(
3-
`index` bigint unsigned auto_increment
4-
primary key,
5-
afk_timeout int null,
6-
allow_accessibility_detection tinyint null,
7-
animate_emoji tinyint null,
8-
animate_stickers int null,
9-
contact_sync_enabled tinyint null,
10-
convert_emoticons tinyint null,
11-
custom_status text null,
12-
default_guilds_restricted tinyint null,
13-
detect_platform_accounts tinyint null,
14-
developer_mode tinyint null,
15-
disable_games_tab tinyint null,
16-
enable_tts_command tinyint null,
17-
explicit_content_filter int null,
18-
friend_source_flags text null,
19-
gateway_connected tinyint null,
20-
gif_auto_play tinyint null,
21-
guild_folders text null,
22-
guild_positions text null,
23-
inline_attachment_media tinyint null,
24-
inline_embed_media tinyint null,
25-
locale varchar(255) null,
26-
message_display_compact tinyint null,
27-
native_phone_integration_enabled tinyint null,
28-
render_embeds tinyint null,
29-
render_reactions tinyint null,
30-
restricted_guilds text null,
31-
show_current_game tinyint null,
32-
status varchar(255) null,
33-
stream_notifications_enabled tinyint null,
34-
theme varchar(255) null,
35-
timezone_offset int null
5+
index numeric(20, 0) not null default nextval('user_settings_index_seq') constraint chk_index_range check (index >= 0 and index <= 18446744073709551615) primary key,
6+
afk_timeout int null,
7+
allow_accessibility_detection smallint null,
8+
animate_emoji smallint null,
9+
animate_stickers int null,
10+
contact_sync_enabled smallint null,
11+
convert_emoticons smallint null,
12+
custom_status text null,
13+
default_guilds_restricted smallint null,
14+
detect_platform_accounts smallint null,
15+
developer_mode smallint null,
16+
disable_games_tab smallint null,
17+
enable_tts_command smallint null,
18+
explicit_content_filter int null,
19+
friend_source_flags text null,
20+
gateway_connected smallint null,
21+
gif_auto_play smallint null,
22+
guild_folders text null,
23+
guild_positions text null,
24+
inline_attachment_media smallint null,
25+
inline_embed_media smallint null,
26+
locale varchar(255) null,
27+
message_display_compact smallint null,
28+
native_phone_integration_enabled smallint null,
29+
render_embeds smallint null,
30+
render_reactions smallint null,
31+
restricted_guilds text null,
32+
show_current_game smallint null,
33+
status varchar(255) null,
34+
stream_notifications_enabled smallint null,
35+
theme varchar(255) null,
36+
timezone_offset int null
3637
);
3738

0 commit comments

Comments
 (0)