Skip to content

Commit

Permalink
Merge branch 'backend' of github.com:pilksoc/CosmicKube into backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ettolrach committed Mar 2, 2024
2 parents 8a4d472 + c486a62 commit 99894df
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ Cargo.lock

backend/target/

.env

.env
33 changes: 33 additions & 0 deletions backend/src/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// @generated automatically by Diesel CLI.

diesel::table! {
kube_recipe_lines (recipe_id) {
recipe_id -> Uuid,
input_id -> Uuid,
}
}

diesel::table! {
kube_recipes (id) {
id -> Uuid,
output_id -> Uuid,
}
}

diesel::table! {
kubes (id) {
id -> Uuid,
#[max_length = 255]
name -> Varchar,
}
}

diesel::joinable!(kube_recipe_lines -> kube_recipes (recipe_id));
diesel::joinable!(kube_recipe_lines -> kubes (input_id));
diesel::joinable!(kube_recipes -> kubes (output_id));

diesel::allow_tables_to_appear_in_same_query!(
kube_recipe_lines,
kube_recipes,
kubes,
);
2 changes: 1 addition & 1 deletion diesel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# see https://diesel.rs/guides/configuring-diesel-cli

[print_schema]
file = "src/schema.rs"
file = "backend/src/schema.rs"
custom_type_derives = ["diesel::query_builder::QueryId"]

[migrations_directory]
Expand Down
5 changes: 5 additions & 0 deletions migrations/2024-03-02-174331_create_init_db/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- This file should undo anything in `up.sql`

DROP TABLE kubes_recipe_lines;
DROP TABLE kubes_recipes;
DROP TABLE kubes;
20 changes: 20 additions & 0 deletions migrations/2024-03-02-174331_create_init_db/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Your SQL goes here

CREATE TABLE kubes (
id uuid primary key,
name varchar(255) not null
);

CREATE INDEX k_i on kubes(name);

CREATE TABLE kube_recipes (
id uuid primary key,
output_id uuid not null references kubes(id)
);

CREATE TABLE kube_recipe_lines (
recipe_id uuid primary key references kube_recipes(id),
input_id uuid not null references kubes(id)
);

CREATE INDEX krl_i ON kube_recipe_lines(recipe_id, input_id);

0 comments on commit 99894df

Please sign in to comment.