diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-05 20:34:20 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-05 20:34:20 +0200 |
commit | b3df5c6f8cc59e099a2f1db3df8089af4abca02e (patch) | |
tree | 8b717834ab72165610b1548bb080a3299d936936 /planetwars-server/src/db/bots.rs | |
parent | 8a47b948eb88f1e0ff649880a70f9416306bac92 (diff) | |
download | planetwars.dev-b3df5c6f8cc59e099a2f1db3df8089af4abca02e.tar.xz planetwars.dev-b3df5c6f8cc59e099a2f1db3df8089af4abca02e.zip |
migrate code_bundles to bot_versions
Diffstat (limited to 'planetwars-server/src/db/bots.rs')
-rw-r--r-- | planetwars-server/src/db/bots.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/planetwars-server/src/db/bots.rs b/planetwars-server/src/db/bots.rs index 108c692..964deaa 100644 --- a/planetwars-server/src/db/bots.rs +++ b/planetwars-server/src/db/bots.rs @@ -1,7 +1,7 @@ use diesel::prelude::*; use serde::{Deserialize, Serialize}; -use crate::schema::{bots, code_bundles}; +use crate::schema::{bot_versions, bots}; use chrono; #[derive(Insertable)] @@ -44,38 +44,39 @@ pub fn find_all_bots(conn: &PgConnection) -> QueryResult<Vec<Bot>> { } #[derive(Insertable)] -#[table_name = "code_bundles"] +#[table_name = "bot_versions"] pub struct NewCodeBundle<'a> { pub bot_id: Option<i32>, - pub path: &'a str, + pub code_bundle_path: &'a str, } #[derive(Queryable, Serialize, Deserialize, Debug)] pub struct CodeBundle { pub id: i32, pub bot_id: Option<i32>, - pub path: String, + pub code_bundle_path: Option<String>, pub created_at: chrono::NaiveDateTime, + pub container_digest: Option<String>, } pub fn create_code_bundle( new_code_bundle: &NewCodeBundle, conn: &PgConnection, ) -> QueryResult<CodeBundle> { - diesel::insert_into(code_bundles::table) + diesel::insert_into(bot_versions::table) .values(new_code_bundle) .get_result(conn) } pub fn find_bot_code_bundles(bot_id: i32, conn: &PgConnection) -> QueryResult<Vec<CodeBundle>> { - code_bundles::table - .filter(code_bundles::bot_id.eq(bot_id)) + bot_versions::table + .filter(bot_versions::bot_id.eq(bot_id)) .get_results(conn) } pub fn active_code_bundle(bot_id: i32, conn: &PgConnection) -> QueryResult<CodeBundle> { - code_bundles::table - .filter(code_bundles::bot_id.eq(bot_id)) - .order(code_bundles::created_at.desc()) + bot_versions::table + .filter(bot_versions::bot_id.eq(bot_id)) + .order(bot_versions::created_at.desc()) .first(conn) } |