summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-02-05 15:28:42 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-02-05 15:30:21 +0100
commit2a1e017c063c462da3702e0227cb075643013988 (patch)
treee28c9b7d3dc96a3d83d3da9384effdd92b506e6a
parent2852e1b6e9a3987d923e6fe774172a00a12b9192 (diff)
Remove "tree" from submit
This removes the "tree" column from the "submits" table. This is because we do not store the build-tree in the database anymore. We don't actually need this feature and we can always re-build the tree from an old commit in the repository. Thus, this is not required anymore. Also, it is less easy to do as soon as the internal implementation changes from a "tree" structure to a "DAG" structure. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--migrations/2021-02-05-142606_remove-package-tree-json-from-submit/down.sql5
-rw-r--r--migrations/2021-02-05-142606_remove-package-tree-json-from-submit/up.sql5
-rw-r--r--src/commands/build.rs1
-rw-r--r--src/db/models/submit.rs9
-rw-r--r--src/schema.rs1
5 files changed, 10 insertions, 11 deletions
diff --git a/migrations/2021-02-05-142606_remove-package-tree-json-from-submit/down.sql b/migrations/2021-02-05-142606_remove-package-tree-json-from-submit/down.sql
new file mode 100644
index 0000000..a7348ee
--- /dev/null
+++ b/migrations/2021-02-05-142606_remove-package-tree-json-from-submit/down.sql
@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE
+ submits
+ADD COLUMN
+ tree JSONB NOT NULL
diff --git a/migrations/2021-02-05-142606_remove-package-tree-json-from-submit/up.sql b/migrations/2021-02-05-142606_remove-package-tree-json-from-submit/up.sql
new file mode 100644
index 0000000..531d746
--- /dev/null
+++ b/migrations/2021-02-05-142606_remove-package-tree-json-from-submit/up.sql
@@ -0,0 +1,5 @@
+-- Your SQL goes here
+ALTER TABLE
+ submits
+DROP COLUMN
+ tree
diff --git a/src/commands/build.rs b/src/commands/build.rs
index 3f168fa..b1d3e58 100644
--- a/src/commands/build.rs
+++ b/src/commands/build.rs
@@ -291,7 +291,6 @@ pub async fn build(
trace!("Creating Submit in database");
let submit = Submit::create(
&database_connection,
- &tree,
&now,
&submit_id,
&db_image,
diff --git a/src/db/models/submit.rs b/src/db/models/submit.rs
index a33bf96..7792adf 100644
--- a/src/db/models/submit.rs
+++ b/src/db/models/submit.rs
@@ -8,7 +8,6 @@
// SPDX-License-Identifier: EPL-2.0
//
-use anyhow::anyhow;
use anyhow::Context;
use anyhow::Error;
use anyhow::Result;
@@ -33,7 +32,6 @@ pub struct Submit {
pub requested_image_id: i32,
pub requested_package_id: i32,
pub repo_hash_id: i32,
- pub tree: serde_json::Value,
}
#[derive(Insertable)]
@@ -44,30 +42,23 @@ struct NewSubmit<'a> {
pub requested_image_id: i32,
pub requested_package_id: i32,
pub repo_hash_id: i32,
- pub tree: serde_json::Value,
}
impl Submit {
pub fn create(
database_connection: &PgConnection,
- t: &crate::package::Tree,
submit_datetime: &NaiveDateTime,
submit_id: &::uuid::Uuid,
requested_image: &Image,
requested_package: &Package,
repo_hash: &GitHash,
) -> Result<Submit> {
- let tree_json = serde_json::to_value(t)
- .context("Converting tree to JSON string")
- .with_context(|| anyhow!("Tree = {:#?}", t))?;
-
let new_submit = NewSubmit {
uuid: submit_id,
submit_time: submit_datetime,
requested_image_id: requested_image.id,
requested_package_id: requested_package.id,
repo_hash_id: repo_hash.id,
- tree: tree_json,
};
diesel::insert_into(submits::table)
diff --git a/src/schema.rs b/src/schema.rs
index 676b0f7..d888dcd 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -105,7 +105,6 @@ table! {
requested_image_id -> Int4,
requested_package_id -> Int4,
repo_hash_id -> Int4,
- tree -> Jsonb,
}
}