From 8de1efcd7f911a5c443ed774f0bd64f5d579bf3e Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sun, 27 Jun 2021 16:54:13 +0200 Subject: [PATCH 1/4] Added first draft database schema --- .../2021-06-27-131430_initial_schema/down.sql | 4 +++ .../2021-06-27-131430_initial_schema/up.sql | 34 +++++++++++++++++++ src/schema.rs | 33 ++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 migrations/2021-06-27-131430_initial_schema/down.sql create mode 100644 migrations/2021-06-27-131430_initial_schema/up.sql create mode 100644 src/schema.rs diff --git a/migrations/2021-06-27-131430_initial_schema/down.sql b/migrations/2021-06-27-131430_initial_schema/down.sql new file mode 100644 index 0000000..3035882 --- /dev/null +++ b/migrations/2021-06-27-131430_initial_schema/down.sql @@ -0,0 +1,4 @@ +-- This file should undo anything in `up.sql` +DROP TABLE packages; +DROP TABLE maintainers; +DROP TYPE package_type; \ No newline at end of file diff --git a/migrations/2021-06-27-131430_initial_schema/up.sql b/migrations/2021-06-27-131430_initial_schema/up.sql new file mode 100644 index 0000000..60b03f4 --- /dev/null +++ b/migrations/2021-06-27-131430_initial_schema/up.sql @@ -0,0 +1,34 @@ +CREATE TABLE maintainers ( + id uuid DEFAULT gen_random_uuid() PRIMARY KEY, + + name text NOT NULL, + email text NOT NULL, + + UNIQUE (name, email) +); + +CREATE TYPE package_type AS ENUM ('deb', 'dsc', 'udeb'); + +-- Table containing information about a package +CREATE TABLE packages ( + id uuid DEFAULT gen_random_uuid() PRIMARY KEY, + + name text NOT NULL, + type package_type NOT NULL, + version text NOT NULL, + -- This is just text, as there's no guarantee the source is present on this + -- repository. + source text, + section text, + priority text, + -- NOTE: could this be better than just text? + architecture text NOT NULL, + essential boolean DEFAULT false, + installed_size integer, + maintainer_id uuid REFERENCES maintainers (id) NOT NULL, + description text NOT NULL, + homepage text, + + -- NOTE: I don't think this is enough because architecture can be a wildcard + UNIQUE (name, version, architecture) +); \ No newline at end of file diff --git a/src/schema.rs b/src/schema.rs new file mode 100644 index 0000000..60c0838 --- /dev/null +++ b/src/schema.rs @@ -0,0 +1,33 @@ +table! { + maintainers (id) { + id -> Uuid, + name -> Text, + email -> Text, + } +} + +table! { + packages (id) { + id -> Uuid, + name -> Text, + #[sql_name = "type"] + type_ -> Package_type, + version -> Text, + source -> Nullable, + section -> Nullable, + priority -> Nullable, + architecture -> Text, + essential -> Nullable, + installed_size -> Nullable, + maintainer_id -> Uuid, + description -> Text, + homepage -> Nullable, + } +} + +joinable!(packages -> maintainers (maintainer_id)); + +allow_tables_to_appear_in_same_query!( + maintainers, + packages, +); From d76a501c355e86a49b0d0df425a81eb36f89efea Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 24 Dec 2021 08:01:59 +0000 Subject: [PATCH 2/4] Update Rust crate diesel to 1.4.8 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ec71b8..1cf7bc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,9 +178,9 @@ dependencies = [ [[package]] name = "diesel" -version = "1.4.7" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba51ca66f57261fd17cadf8b73e4775cc307d0521d855de3f5de91a8f074e0e" +checksum = "b28135ecf6b7d446b43e27e225622a038cc4e2930a1022f51cdb97ada19b8e4d" dependencies = [ "bitflags", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index 6e66641..6375ee6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] rocket = "0.5.0-rc.1" -diesel = { version = "1.4.7", features = ["postgres"] } +diesel = { version = "1.4.8", features = ["postgres"] } diesel_migrations = "1.4.0" [dependencies.rocket_sync_db_pools] From 3311fd2373bc26573e8cb3492bc372472b574b37 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 24 Dec 2021 08:02:01 +0000 Subject: [PATCH 3/4] Update alpine Docker tag to v3.15 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6b28746..c64b43f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN cargo build \ --release -FROM alpine:3.13 +FROM alpine:3.15 COPY --from=builder /src/target/release/hilde /usr/local/bin/hilde From c908dc7e9c433d5f60b86350eb7d99030a99a64b Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 24 Dec 2021 08:02:03 +0000 Subject: [PATCH 4/4] Update rust Docker tag to v1.57 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6b28746..d1ca267 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.53-alpine3.13 AS builder +FROM rust:1.57-alpine3.13 AS builder WORKDIR /src