diff --git a/rust-backend/migrations/V3__create_reviews_table.sql b/rust-backend/migrations/V3__create_reviews_table.sql new file mode 100644 index 0000000..6ab31b4 --- /dev/null +++ b/rust-backend/migrations/V3__create_reviews_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE reviews ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id TEXT NOT NULL, + lat REAL NOT NULL, + lng REAL NOT NULL, + place_name TEXT NOT NULL, + place_description TEXT NOT NULL, + title TEXT NOT NULL, + content TEXT NOT NULL, + rating REAL NOT NULL +); + diff --git a/rust-backend/src/models.rs b/rust-backend/src/models.rs index 4892d0b..c4933ac 100644 --- a/rust-backend/src/models.rs +++ b/rust-backend/src/models.rs @@ -25,3 +25,32 @@ impl Favorite { } } +#[derive(Serialize)] +pub struct Review { + pub id: i64, + pub user_id: String, + pub lat: f64, + pub lng: f64, + pub place_name: String, + pub place_description: String, + pub title: String, + pub content: String, + pub rating: i64, +} + +impl Review { + pub fn from_row(row: &Row) -> Result { + Ok(Review { + id: row.get("id")?, + user_id: row.get("user_id")?, + lat: row.get("lat")?, + lng: row.get("lng")?, + place_name: row.get("place_name")?, + place_description: row.get("place_description")?, + title: row.get("title")?, + content: row.get("content")?, + rating: row.get("rating")?, + }) + } +} +