Coverage for opt/mealie/lib/python3.12/site-packages/mealie/alembic/versions/2023-10-19-19.22.55_ba1e4a6cfe99_added_plural_names_and_alias_tables_for_.py: 62%

39 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 13:45 +0000

1"""added plural names and alias tables for foods and units 

2 

3Revision ID: ba1e4a6cfe99 

4Revises: dded3119c1fe 

5Create Date: 2023-10-19 19:22:55.369319 

6 

7""" 

8 

9import sqlalchemy as sa 1a

10 

11import mealie.db.migration_types 1a

12from alembic import op 1a

13 

14# revision identifiers, used by Alembic. 

15revision = "ba1e4a6cfe99" 1a

16down_revision = "dded3119c1fe" 1a

17branch_labels: str | tuple[str, ...] | None = None 1a

18depends_on: str | tuple[str, ...] | None = None 1a

19 

20 

21def upgrade(): 1a

22 # ### commands auto generated by Alembic - please adjust! ### 

23 op.create_table( 1a

24 "ingredient_units_aliases", 

25 sa.Column("id", mealie.db.migration_types.GUID(), nullable=False), 

26 sa.Column("unit_id", mealie.db.migration_types.GUID(), nullable=False), 

27 sa.Column("name", sa.String(), nullable=False), 

28 sa.Column("name_normalized", sa.String(), nullable=True), 

29 sa.Column("created_at", sa.DateTime(), nullable=True), 

30 sa.Column("update_at", sa.DateTime(), nullable=True), 

31 sa.ForeignKeyConstraint( 

32 ["unit_id"], 

33 ["ingredient_units.id"], 

34 ), 

35 sa.PrimaryKeyConstraint("id", "unit_id"), 

36 ) 

37 op.create_index( 1a

38 op.f("ix_ingredient_units_aliases_created_at"), "ingredient_units_aliases", ["created_at"], unique=False 

39 ) 

40 op.create_index( 1a

41 op.f("ix_ingredient_units_aliases_name_normalized"), 

42 "ingredient_units_aliases", 

43 ["name_normalized"], 

44 unique=False, 

45 ) 

46 op.create_table( 1a

47 "ingredient_foods_aliases", 

48 sa.Column("id", mealie.db.migration_types.GUID(), nullable=False), 

49 sa.Column("food_id", mealie.db.migration_types.GUID(), nullable=False), 

50 sa.Column("name", sa.String(), nullable=False), 

51 sa.Column("name_normalized", sa.String(), nullable=True), 

52 sa.Column("created_at", sa.DateTime(), nullable=True), 

53 sa.Column("update_at", sa.DateTime(), nullable=True), 

54 sa.ForeignKeyConstraint( 

55 ["food_id"], 

56 ["ingredient_foods.id"], 

57 ), 

58 sa.PrimaryKeyConstraint("id", "food_id"), 

59 ) 

60 op.create_index( 1a

61 op.f("ix_ingredient_foods_aliases_created_at"), "ingredient_foods_aliases", ["created_at"], unique=False 

62 ) 

63 op.create_index( 1a

64 op.f("ix_ingredient_foods_aliases_name_normalized"), 

65 "ingredient_foods_aliases", 

66 ["name_normalized"], 

67 unique=False, 

68 ) 

69 op.add_column("ingredient_foods", sa.Column("plural_name", sa.String(), nullable=True)) 1a

70 op.add_column("ingredient_foods", sa.Column("plural_name_normalized", sa.String(), nullable=True)) 1a

71 op.create_index( 1a

72 op.f("ix_ingredient_foods_plural_name_normalized"), "ingredient_foods", ["plural_name_normalized"], unique=False 

73 ) 

74 op.add_column("ingredient_units", sa.Column("plural_name", sa.String(), nullable=True)) 1a

75 op.add_column("ingredient_units", sa.Column("plural_name_normalized", sa.String(), nullable=True)) 1a

76 op.create_index( 1a

77 op.f("ix_ingredient_units_plural_name_normalized"), "ingredient_units", ["plural_name_normalized"], unique=False 

78 ) 

79 op.add_column("ingredient_units", sa.Column("plural_abbreviation", sa.String(), nullable=True)) 1a

80 op.add_column("ingredient_units", sa.Column("plural_abbreviation_normalized", sa.String(), nullable=True)) 1a

81 op.create_index( 1a

82 op.f("ix_ingredient_units_plural_abbreviation_normalized"), 

83 "ingredient_units", 

84 ["plural_abbreviation_normalized"], 

85 unique=False, 

86 ) 

87 # ### end Alembic commands ### 

88 

89 

90def downgrade(): 1a

91 # ### commands auto generated by Alembic - please adjust! ### 

92 op.drop_index(op.f("ix_ingredient_units_plural_abbreviation_normalized"), table_name="ingredient_units") 

93 op.drop_column("ingredient_units", "plural_abbreviation_normalized") 

94 op.drop_column("ingredient_units", "plural_abbreviation") 

95 op.drop_index(op.f("ix_ingredient_units_plural_name_normalized"), table_name="ingredient_units") 

96 op.drop_column("ingredient_units", "plural_name_normalized") 

97 op.drop_column("ingredient_units", "plural_name") 

98 op.drop_index(op.f("ix_ingredient_foods_plural_name_normalized"), table_name="ingredient_foods") 

99 op.drop_column("ingredient_foods", "plural_name_normalized") 

100 op.drop_column("ingredient_foods", "plural_name") 

101 op.drop_index(op.f("ix_ingredient_foods_aliases_name_normalized"), table_name="ingredient_foods_aliases") 

102 op.drop_index(op.f("ix_ingredient_foods_aliases_created_at"), table_name="ingredient_foods_aliases") 

103 op.drop_table("ingredient_foods_aliases") 

104 op.drop_index(op.f("ix_ingredient_units_aliases_name_normalized"), table_name="ingredient_units_aliases") 

105 op.drop_index(op.f("ix_ingredient_units_aliases_created_at"), table_name="ingredient_units_aliases") 

106 op.drop_table("ingredient_units_aliases") 

107 # ### end Alembic commands ###