- remove: duplicated data entries in the character db schema
This commit is contained in:
@@ -41,7 +41,7 @@ impl CharacterRepository {
|
||||
|
||||
// Fetch from database
|
||||
let character = sqlx::query_as::<_, Character>(
|
||||
"SELECT id, user_id, name, level, experience, inventory, stats, looks, position, \
|
||||
"SELECT id, user_id, name, inventory, stats, looks, position, \
|
||||
created_at, updated_at, deleted_at, is_active \
|
||||
FROM characters WHERE id = $1 AND is_active = true",
|
||||
)
|
||||
@@ -56,7 +56,7 @@ impl CharacterRepository {
|
||||
|
||||
pub async fn create_character(&self, user_id: i32, name: &str, inventory: serde_json::Value, stats: serde_json::Value, looks: serde_json::Value, position: serde_json::Value) -> Result<i32, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
"INSERT INTO characters (user_id, name, level, experience, inventory, stats, looks, position, created_at, updated_at, is_active) \
|
||||
"INSERT INTO characters (user_id, name, inventory, stats, looks, position, created_at, updated_at, is_active) \
|
||||
VALUES ($1, $2, 1, 0, $3, $4, $5, $6, NOW(), NOW(), true) RETURNING id",
|
||||
)
|
||||
.bind(user_id)
|
||||
@@ -95,7 +95,7 @@ impl CharacterRepository {
|
||||
|
||||
// Fetch from database
|
||||
let characters = sqlx::query_as::<_, Character>(
|
||||
"SELECT id, user_id, name, level, experience, inventory, stats, looks, position, \
|
||||
"SELECT id, user_id, name, inventory, stats, looks, position, \
|
||||
created_at, updated_at, deleted_at, is_active \
|
||||
FROM characters WHERE user_id = $1 AND is_active = true",
|
||||
)
|
||||
|
||||
@@ -39,8 +39,6 @@ create table characters
|
||||
on delete cascade,
|
||||
is_active boolean default true,
|
||||
name varchar(50) not null,
|
||||
level smallint default 1,
|
||||
experience bigint default 0,
|
||||
inventory jsonb default '{}'::jsonb,
|
||||
stats jsonb default '{}'::jsonb,
|
||||
looks jsonb default '{}'::jsonb,
|
||||
|
||||
Reference in New Issue
Block a user