use sqlx migrations
This commit is contained in:
4
migrations/20250626163902_bank.sql
Normal file
4
migrations/20250626163902_bank.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS bank (
|
||||||
|
id BIGINT PRIMARY KEY,
|
||||||
|
balance INT
|
||||||
|
)
|
||||||
8
migrations/20250626164104_selfroles.sql
Normal file
8
migrations/20250626164104_selfroles.sql
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS selfroles (
|
||||||
|
userid BIGINT NOT NULL,
|
||||||
|
guildid BIGINT NOT NULL,
|
||||||
|
roleid BIGINT,
|
||||||
|
UNIQUE (userid, guildid)
|
||||||
|
)
|
||||||
|
|
||||||
6
migrations/20250626164333_games.sql
Normal file
6
migrations/20250626164333_games.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS games (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
name CHAR[255]
|
||||||
|
)
|
||||||
|
|
||||||
8
migrations/20250626164633_items.sql
Normal file
8
migrations/20250626164633_items.sql
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS items (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
owner BIGINT NOT NULL,
|
||||||
|
game BIGINT NOT NULL,
|
||||||
|
item BIGINT NOT NULL,
|
||||||
|
data JSON NOT NULL,
|
||||||
|
name TEXT
|
||||||
|
)
|
||||||
5
migrations/20250626164737_dailies.sql
Normal file
5
migrations/20250626164737_dailies.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS dailies (
|
||||||
|
userid BIGINT NOT NULL PRIMARY KEY,
|
||||||
|
last TIMESTAMPTZ,
|
||||||
|
streak INT
|
||||||
|
)
|
||||||
7
migrations/20250626164817_settings.sql
Normal file
7
migrations/20250626164817_settings.sql
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS settings (
|
||||||
|
guildid BIGINT NOT NULL PRIMARY KEY,
|
||||||
|
positional_role BIGINT,
|
||||||
|
banrole BIGINT,
|
||||||
|
hoist_selfroles BOOLEAN,
|
||||||
|
prefix TEXT
|
||||||
|
)
|
||||||
66
src/main.rs
66
src/main.rs
@@ -111,69 +111,9 @@ async fn main() -> Result<(), Error> {
|
|||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
.connect(&database_url).await?;
|
.connect(&database_url).await?;
|
||||||
|
|
||||||
sqlx::query(
|
sqlx::migrate!()
|
||||||
r#"
|
.run(&database)
|
||||||
CREATE TABLE IF NOT EXISTS bank (
|
.await?;
|
||||||
id BIGINT PRIMARY KEY,
|
|
||||||
balance INT
|
|
||||||
)
|
|
||||||
"#,
|
|
||||||
).execute(&database).await?;
|
|
||||||
|
|
||||||
sqlx::query(
|
|
||||||
r#"
|
|
||||||
CREATE TABLE IF NOT EXISTS selfroles (
|
|
||||||
userid BIGINT NOT NULL,
|
|
||||||
guildid BIGINT NOT NULL,
|
|
||||||
roleid BIGINT,
|
|
||||||
UNIQUE (userid, guildid)
|
|
||||||
)
|
|
||||||
"#,
|
|
||||||
).execute(&database).await?;
|
|
||||||
|
|
||||||
sqlx::query(
|
|
||||||
r#"
|
|
||||||
CREATE TABLE IF NOT EXISTS games (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
name CHAR[255]
|
|
||||||
)
|
|
||||||
"#
|
|
||||||
).execute(&database).await?;
|
|
||||||
|
|
||||||
sqlx::query(
|
|
||||||
r#"
|
|
||||||
CREATE TABLE IF NOT EXISTS items (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
owner BIGINT NOT NULL,
|
|
||||||
game BIGINT NOT NULL,
|
|
||||||
item BIGINT NOT NULL,
|
|
||||||
data JSON NOT NULL,
|
|
||||||
name TEXT
|
|
||||||
)
|
|
||||||
"#
|
|
||||||
).execute(&database).await?;
|
|
||||||
|
|
||||||
sqlx::query(
|
|
||||||
r#"
|
|
||||||
CREATE TABLE IF NOT EXISTS dailies (
|
|
||||||
userid BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
last TIMESTAMPTZ,
|
|
||||||
streak INT
|
|
||||||
)
|
|
||||||
"#
|
|
||||||
).execute(&database).await?;
|
|
||||||
|
|
||||||
sqlx::query(
|
|
||||||
r#"
|
|
||||||
CREATE TABLE IF NOT EXISTS settings (
|
|
||||||
guildid BIGINT NOT NULL PRIMARY KEY,
|
|
||||||
positional_role BIGINT,
|
|
||||||
banrole BIGINT,
|
|
||||||
hoist_selfroles BOOLEAN,
|
|
||||||
prefix TEXT
|
|
||||||
)
|
|
||||||
"#
|
|
||||||
).execute(&database).await?;
|
|
||||||
|
|
||||||
println!("Bot is ready!");
|
println!("Bot is ready!");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user