Skip to content

Commit 57aa97f

Browse files
authored
Merge pull request #5767 from msupply-foundation/5743-remove-site-id-column-from-contact-form
remove contact forms side id
2 parents f775ea1 + 700112a commit 57aa97f

File tree

10 files changed

+62
-23
lines changed

10 files changed

+62
-23
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
on:
2+
workflow_dispatch:
3+
4+
name: Manual Cargo Clean
5+
6+
jobs:
7+
build_and_test:
8+
name: Run cargo clean against self-hosted
9+
runs-on: self-hosted
10+
timeout-minutes: 25
11+
steps:
12+
- name: Update PATH
13+
run: echo "$HOME/.cargo/bin:/opt/homebrew/bin" >> $GITHUB_PATH
14+
- uses: actions/checkout@v4
15+
- uses: actions-rs/toolchain@v1
16+
with:
17+
toolchain: stable
18+
- name: Clean SQLite Artifacts
19+
env:
20+
CARGO_TARGET_DIR: /tmp/target/sqlite
21+
uses: actions-rs/cargo@v1
22+
with:
23+
command: clean
24+
args: --manifest-path server/Cargo.toml
25+
- name: Clean PostgreSQL artifacts
26+
env:
27+
CARGO_TARGET_DIR: /tmp/target/postgres
28+
uses: actions-rs/cargo@v1
29+
with:
30+
command: clean
31+
args: --manifest-path server/Cargo.toml
32+
33+
34+

.github/workflows/server-tests.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions-rs/cargo@v1
2727
with:
2828
command: clean
29-
args: -p repository -p graphql_types -p graphql_plugin --manifest-path server/Cargo.toml
29+
args: -p repository -p graphql_types -p graphql_plugin -p graphql_invoice --manifest-path server/Cargo.toml
3030
- uses: actions-rs/cargo@v1
3131
with:
3232
command: test
@@ -47,7 +47,7 @@ jobs:
4747
- uses: actions-rs/cargo@v1
4848
with:
4949
command: clean
50-
args: -p repository -p graphql_types -p graphql_plugin --manifest-path server/Cargo.toml
50+
args: -p repository -p graphql_types -p graphql_plugin -p graphql_invoice --manifest-path server/Cargo.toml
5151
- uses: actions-rs/cargo@v1
5252
with:
5353
command: test

server/graphql/contact_form/src/mutations/insert.rs

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ pub fn insert_contact_form(
5050
map_response(service_provider.contact_form_service.insert_contact_form(
5151
&service_context,
5252
&store_id,
53-
// &service_provider
54-
// .site_info_service
55-
// .get_site_id(&service_context)?
56-
"Todo: update type of site id in service layer and database table",
5753
input.to_domain(),
5854
))
5955
}

server/repository/src/db_diesel/contact_form_row.rs

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ table! {
2020
created_datetime -> Timestamp,
2121
user_id -> Text,
2222
store_id -> Text,
23-
site_id -> Text,
2423
contact_type -> crate::db_diesel::contact_form_row::ContactTypeMapping,
2524
}
2625
}
@@ -38,7 +37,6 @@ pub struct ContactFormRow {
3837
pub reply_email: String,
3938
pub body: String,
4039
pub created_datetime: NaiveDateTime,
41-
pub site_id: String,
4240
pub store_id: String,
4341
pub user_id: String,
4442
pub contact_type: ContactType,

server/repository/src/migrations/v2_05_00/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod add_contact_form_table;
55
mod add_emergency_orders;
66
mod item_direction_create_table;
77
mod new_store_preferences;
8+
mod remove_contact_form_site_id;
89
mod remove_unique_description_on_tmp_breach;
910

1011
use crate::StorageConnection;
@@ -27,6 +28,7 @@ impl Migration for V2_05_00 {
2728
Box::new(remove_unique_description_on_tmp_breach::Migrate),
2829
Box::new(add_emergency_orders::Migrate),
2930
Box::new(abbreviation_create_table::Migrate),
31+
Box::new(remove_contact_form_site_id::Migrate),
3032
Box::new(item_direction_create_table::Migrate),
3133
]
3234
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use crate::migrations::*;
2+
3+
pub(crate) struct Migrate;
4+
5+
impl MigrationFragment for Migrate {
6+
fn identifier(&self) -> &'static str {
7+
"remove_contact_form_site_id"
8+
}
9+
10+
fn migrate(&self, connection: &StorageConnection) -> anyhow::Result<()> {
11+
// Dropped as not needed
12+
sql!(
13+
connection,
14+
r#"
15+
ALTER TABLE contact_form DROP COLUMN site_id;
16+
"#
17+
)?;
18+
19+
Ok(())
20+
}
21+
}

server/service/src/contact_form/insert/generate.rs

-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ use super::InsertContactForm;
66
pub struct GenerateInput {
77
pub store_id: String,
88
pub user_id: String,
9-
pub site_id: String,
109
pub insert_input: InsertContactForm,
1110
}
1211

1312
pub fn generate(
1413
GenerateInput {
1514
store_id,
1615
user_id,
17-
site_id,
1816
insert_input,
1917
}: GenerateInput,
2018
) -> ContactFormRow {
@@ -33,7 +31,6 @@ pub fn generate(
3331
created_datetime: now,
3432
reply_email,
3533
body,
36-
site_id,
3734
//harcoded contact type until optional types available in front end
3835
contact_type: ContactType::Feedback,
3936
}

server/service/src/contact_form/insert/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub struct InsertContactForm {
3030
pub fn insert_contact_form(
3131
ctx: &ServiceContext,
3232
store_id: &str,
33-
site_id: &str,
3433
input: InsertContactForm,
3534
) -> Result<ContactFormRow, InsertContactFormError> {
3635
let new_contact_form = ctx
@@ -43,7 +42,6 @@ pub fn insert_contact_form(
4342
store_id: store_id.to_string(),
4443
user_id: ctx.user_id.clone(),
4544
insert_input: input.clone(),
46-
site_id: site_id.to_string(),
4745
});
4846

4947
//create the contact form

server/service/src/contact_form/insert/test.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ mod insert {
3232
service.insert_contact_form(
3333
&context,
3434
store_id,
35-
&user_id,
3635
InsertContactForm {
3736
id: "test_id".to_string(),
3837
reply_email: "not_an_email".to_string(),
@@ -48,7 +47,6 @@ mod insert {
4847
service.insert_contact_form(
4948
&context,
5049
store_id,
51-
&user_id,
5250
InsertContactForm {
5351
id: "test_id".to_string(),
5452
reply_email: "not_an_email.com".to_string(),
@@ -64,7 +62,6 @@ mod insert {
6462
service.insert_contact_form(
6563
&context,
6664
store_id,
67-
&user_id,
6865
InsertContactForm {
6966
id: "test_id".to_string(),
7067
reply_email: "not_an_email@com".to_string(),
@@ -80,7 +77,6 @@ mod insert {
8077
service.insert_contact_form(
8178
&context,
8279
store_id,
83-
&user_id,
8480
InsertContactForm {
8581
id: "test_id".to_string(),
8682
reply_email: "".to_string(),
@@ -96,7 +92,6 @@ mod insert {
9692
service.insert_contact_form(
9793
&context,
9894
store_id,
99-
&user_id,
10095
InsertContactForm {
10196
id: "test_id".to_string(),
10297
reply_email: "[email protected]".to_string(),
@@ -109,11 +104,11 @@ mod insert {
109104

110105
// Create contact form
111106
service
112-
.insert_contact_form(&context, store_id, &user_id, input.clone())
107+
.insert_contact_form(&context, store_id, input.clone())
113108
.unwrap();
114109

115110
// try create a second time
116-
let result = service.insert_contact_form(&context, store_id, &user_id, input);
111+
let result = service.insert_contact_form(&context, store_id, input);
117112

118113
let expected_result = Err(InsertContactFormError::ContactFormAlreadyExists);
119114

@@ -140,7 +135,6 @@ mod insert {
140135
.insert_contact_form(
141136
&context,
142137
store_id,
143-
&user_id,
144138
InsertContactForm {
145139
id: "test_id".to_string(),
146140
reply_email: "[email protected]".to_string(),

server/service/src/contact_form/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ pub trait ContactFormServiceTrait: Sync + Send {
1010
&self,
1111
ctx: &ServiceContext,
1212
store_id: &str,
13-
site_id: &str,
1413
input: InsertContactForm,
1514
) -> Result<ContactFormRow, InsertContactFormError> {
16-
insert::insert_contact_form(ctx, store_id, site_id, input)
15+
insert::insert_contact_form(ctx, store_id, input)
1716
}
1817
}
1918

0 commit comments

Comments
 (0)