Skip to content

Commit f461089

Browse files
committed
fix(database): migrations with inconsistencies
1 parent 9dca27b commit f461089

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libs/database/src/migrations/m20231016_create_collection_to_entity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub static ENTITY_ID_SQL: &str = indoc! { r#"
3737
"exercise_id",
3838
"workout_id"
3939
)
40-
) STORED;
40+
) STORED
4141
"# };
4242
pub static ENTITY_LOT_SQL: &str = indoc! { r#"
4343
GENERATED ALWAYS AS (
@@ -48,7 +48,7 @@ pub static ENTITY_LOT_SQL: &str = indoc! { r#"
4848
WHEN "exercise_id" IS NOT NULL THEN 'exercise'
4949
WHEN "workout_id" IS NOT NULL THEN 'workout'
5050
END
51-
) STORED;
51+
) STORED
5252
"# };
5353

5454
#[derive(Iden)]

libs/database/src/migrations/m20240724_zzz_new_generated_collection_to_entity_columns.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl MigrationTrait for Migration {
1313
db.execute_unprepared(
1414
r#"
1515
ALTER TABLE collection_to_entity
16-
ADD COLUMN entity_id text GENERATED ALWAYS AS (
16+
ADD COLUMN IF NOT EXISTS entity_id text GENERATED ALWAYS AS (
1717
COALESCE(metadata_id,
1818
person_id,
1919
metadata_group_id,
@@ -26,7 +26,7 @@ ADD COLUMN entity_id text GENERATED ALWAYS AS (
2626
db.execute_unprepared(
2727
r#"
2828
ALTER TABLE collection_to_entity
29-
ADD COLUMN entity_lot text GENERATED ALWAYS AS (
29+
ADD COLUMN IF NOT EXISTS entity_lot text GENERATED ALWAYS AS (
3030
CASE
3131
WHEN metadata_id IS NOT NULL THEN 'metadata'
3232
WHEN person_id IS NOT NULL THEN 'person'

0 commit comments

Comments
 (0)