Fred808 commited on
Commit
c0bcc0e
·
verified ·
1 Parent(s): be690c8

Upload 15 files

Browse files
alembic/versions/20250419_1337_66af49b5df72_add_username_column_to_users_table.py ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """add username column to users table
2
+
3
+ Revision ID: 66af49b5df72
4
+ Revises:
5
+ Create Date: 2025-04-19 13:37:38.068026+00:00
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+ from sqlalchemy.dialects import postgresql
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "66af49b5df72"
17
+ down_revision: Union[str, None] = None
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.drop_index("ix_payments_id", table_name="payments")
25
+ op.drop_table("payments")
26
+ op.drop_index("ix_categories_id", table_name="categories")
27
+ op.drop_index("ix_categories_name", table_name="categories")
28
+ op.drop_table("categories")
29
+ op.drop_index("ix_menu_items_id", table_name="menu_items")
30
+ op.drop_index("ix_menu_items_name", table_name="menu_items")
31
+ op.drop_table("menu_items")
32
+ op.add_column(
33
+ "order_items", sa.Column("product_id", sa.Integer(), nullable=False)
34
+ )
35
+ op.add_column(
36
+ "order_items", sa.Column("price", sa.Float(), nullable=False)
37
+ )
38
+ op.alter_column(
39
+ "order_items", "order_id", existing_type=sa.INTEGER(), nullable=False
40
+ )
41
+ op.alter_column(
42
+ "order_items", "quantity", existing_type=sa.INTEGER(), nullable=False
43
+ )
44
+ op.drop_index("ix_order_items_id", table_name="order_items")
45
+ op.drop_constraint(
46
+ "order_items_menu_item_id_fkey", "order_items", type_="foreignkey"
47
+ )
48
+ op.create_foreign_key(
49
+ None, "order_items", "products", ["product_id"], ["id"]
50
+ )
51
+ op.drop_column("order_items", "unit_price")
52
+ op.drop_column("order_items", "menu_item_id")
53
+ op.add_column(
54
+ "orders", sa.Column("customer_id", sa.Integer(), nullable=False)
55
+ )
56
+ op.add_column(
57
+ "orders", sa.Column("branch_id", sa.Integer(), nullable=False)
58
+ )
59
+ op.add_column(
60
+ "orders", sa.Column("updated_at", sa.DateTime(), nullable=False)
61
+ )
62
+ op.alter_column(
63
+ "orders",
64
+ "total_amount",
65
+ existing_type=sa.DOUBLE_PRECISION(precision=53),
66
+ nullable=False,
67
+ )
68
+ op.alter_column(
69
+ "orders", "status", existing_type=sa.VARCHAR(), nullable=False
70
+ )
71
+ op.alter_column(
72
+ "orders",
73
+ "created_at",
74
+ existing_type=postgresql.TIMESTAMP(),
75
+ nullable=False,
76
+ )
77
+ op.drop_index("ix_orders_id", table_name="orders")
78
+ op.drop_constraint("orders_user_id_fkey", "orders", type_="foreignkey")
79
+ op.create_foreign_key(None, "orders", "branches", ["branch_id"], ["id"])
80
+ op.create_foreign_key(None, "orders", "users", ["customer_id"], ["id"])
81
+ op.drop_column("orders", "user_id")
82
+ op.add_column("users", sa.Column("username", sa.String(), nullable=False))
83
+ op.add_column(
84
+ "users", sa.Column("is_active", sa.Boolean(), nullable=False)
85
+ )
86
+ op.add_column(
87
+ "users", sa.Column("is_superuser", sa.Boolean(), nullable=False)
88
+ )
89
+ op.add_column("users", sa.Column("branch_id", sa.Integer(), nullable=True))
90
+ op.alter_column(
91
+ "users", "email", existing_type=sa.VARCHAR(), nullable=False
92
+ )
93
+ op.alter_column(
94
+ "users", "full_name", existing_type=sa.VARCHAR(), nullable=False
95
+ )
96
+ op.alter_column(
97
+ "users", "hashed_password", existing_type=sa.VARCHAR(), nullable=False
98
+ )
99
+ op.alter_column(
100
+ "users",
101
+ "created_at",
102
+ existing_type=postgresql.TIMESTAMP(),
103
+ nullable=False,
104
+ )
105
+ op.drop_index("ix_users_id", table_name="users")
106
+ op.create_index(
107
+ op.f("ix_users_username"), "users", ["username"], unique=True
108
+ )
109
+ op.create_foreign_key(None, "users", "branches", ["branch_id"], ["id"])
110
+ op.drop_column("users", "role")
111
+ # ### end Alembic commands ###
112
+
113
+
114
+ def downgrade() -> None:
115
+ # ### commands auto generated by Alembic - please adjust! ###
116
+ op.add_column(
117
+ "users",
118
+ sa.Column("role", sa.VARCHAR(), autoincrement=False, nullable=True),
119
+ )
120
+ op.drop_constraint(None, "users", type_="foreignkey")
121
+ op.drop_index(op.f("ix_users_username"), table_name="users")
122
+ op.create_index("ix_users_id", "users", ["id"], unique=False)
123
+ op.alter_column(
124
+ "users",
125
+ "created_at",
126
+ existing_type=postgresql.TIMESTAMP(),
127
+ nullable=True,
128
+ )
129
+ op.alter_column(
130
+ "users", "hashed_password", existing_type=sa.VARCHAR(), nullable=True
131
+ )
132
+ op.alter_column(
133
+ "users", "full_name", existing_type=sa.VARCHAR(), nullable=True
134
+ )
135
+ op.alter_column(
136
+ "users", "email", existing_type=sa.VARCHAR(), nullable=True
137
+ )
138
+ op.drop_column("users", "branch_id")
139
+ op.drop_column("users", "is_superuser")
140
+ op.drop_column("users", "is_active")
141
+ op.drop_column("users", "username")
142
+ op.add_column(
143
+ "orders",
144
+ sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True),
145
+ )
146
+ op.drop_constraint(None, "orders", type_="foreignkey")
147
+ op.drop_constraint(None, "orders", type_="foreignkey")
148
+ op.create_foreign_key(
149
+ "orders_user_id_fkey", "orders", "users", ["user_id"], ["id"]
150
+ )
151
+ op.create_index("ix_orders_id", "orders", ["id"], unique=False)
152
+ op.alter_column(
153
+ "orders",
154
+ "created_at",
155
+ existing_type=postgresql.TIMESTAMP(),
156
+ nullable=True,
157
+ )
158
+ op.alter_column(
159
+ "orders", "status", existing_type=sa.VARCHAR(), nullable=True
160
+ )
161
+ op.alter_column(
162
+ "orders",
163
+ "total_amount",
164
+ existing_type=sa.DOUBLE_PRECISION(precision=53),
165
+ nullable=True,
166
+ )
167
+ op.drop_column("orders", "updated_at")
168
+ op.drop_column("orders", "branch_id")
169
+ op.drop_column("orders", "customer_id")
170
+ op.add_column(
171
+ "order_items",
172
+ sa.Column(
173
+ "menu_item_id", sa.INTEGER(), autoincrement=False, nullable=True
174
+ ),
175
+ )
176
+ op.add_column(
177
+ "order_items",
178
+ sa.Column(
179
+ "unit_price",
180
+ sa.DOUBLE_PRECISION(precision=53),
181
+ autoincrement=False,
182
+ nullable=True,
183
+ ),
184
+ )
185
+ op.drop_constraint(None, "order_items", type_="foreignkey")
186
+ op.create_foreign_key(
187
+ "order_items_menu_item_id_fkey",
188
+ "order_items",
189
+ "menu_items",
190
+ ["menu_item_id"],
191
+ ["id"],
192
+ )
193
+ op.create_index("ix_order_items_id", "order_items", ["id"], unique=False)
194
+ op.alter_column(
195
+ "order_items", "quantity", existing_type=sa.INTEGER(), nullable=True
196
+ )
197
+ op.alter_column(
198
+ "order_items", "order_id", existing_type=sa.INTEGER(), nullable=True
199
+ )
200
+ op.drop_column("order_items", "price")
201
+ op.drop_column("order_items", "product_id")
202
+ op.create_table(
203
+ "menu_items",
204
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
205
+ sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
206
+ sa.Column(
207
+ "description", sa.VARCHAR(), autoincrement=False, nullable=True
208
+ ),
209
+ sa.Column(
210
+ "price",
211
+ sa.DOUBLE_PRECISION(precision=53),
212
+ autoincrement=False,
213
+ nullable=True,
214
+ ),
215
+ sa.Column(
216
+ "category_id", sa.INTEGER(), autoincrement=False, nullable=True
217
+ ),
218
+ sa.Column(
219
+ "image_url", sa.VARCHAR(), autoincrement=False, nullable=True
220
+ ),
221
+ sa.Column(
222
+ "is_available", sa.BOOLEAN(), autoincrement=False, nullable=True
223
+ ),
224
+ sa.Column(
225
+ "allergens",
226
+ postgresql.JSON(astext_type=sa.Text()),
227
+ autoincrement=False,
228
+ nullable=True,
229
+ ),
230
+ sa.Column(
231
+ "preparation_time",
232
+ sa.INTEGER(),
233
+ autoincrement=False,
234
+ nullable=True,
235
+ ),
236
+ sa.ForeignKeyConstraint(
237
+ ["category_id"],
238
+ ["categories.id"],
239
+ name="menu_items_category_id_fkey",
240
+ ),
241
+ sa.PrimaryKeyConstraint("id", name="menu_items_pkey"),
242
+ )
243
+ op.create_index("ix_menu_items_name", "menu_items", ["name"], unique=False)
244
+ op.create_index("ix_menu_items_id", "menu_items", ["id"], unique=False)
245
+ op.create_table(
246
+ "categories",
247
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
248
+ sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
249
+ sa.Column(
250
+ "type",
251
+ postgresql.ENUM(
252
+ "SOUPS",
253
+ "SWALLOW",
254
+ "RICE_DISHES",
255
+ "PROTEINS",
256
+ "SMALL_CHOPS",
257
+ "PEPPER_SOUP",
258
+ "SIDES",
259
+ "DRINKS",
260
+ name="categorytype",
261
+ ),
262
+ autoincrement=False,
263
+ nullable=True,
264
+ ),
265
+ sa.Column(
266
+ "description", sa.VARCHAR(), autoincrement=False, nullable=True
267
+ ),
268
+ sa.PrimaryKeyConstraint("id", name="categories_pkey"),
269
+ )
270
+ op.create_index("ix_categories_name", "categories", ["name"], unique=False)
271
+ op.create_index("ix_categories_id", "categories", ["id"], unique=False)
272
+ op.create_table(
273
+ "payments",
274
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
275
+ sa.Column(
276
+ "order_id", sa.INTEGER(), autoincrement=False, nullable=True
277
+ ),
278
+ sa.Column(
279
+ "amount",
280
+ sa.DOUBLE_PRECISION(precision=53),
281
+ autoincrement=False,
282
+ nullable=True,
283
+ ),
284
+ sa.Column("method", sa.VARCHAR(), autoincrement=False, nullable=True),
285
+ sa.Column("status", sa.VARCHAR(), autoincrement=False, nullable=True),
286
+ sa.Column(
287
+ "transaction_id", sa.VARCHAR(), autoincrement=False, nullable=True
288
+ ),
289
+ sa.Column(
290
+ "created_at",
291
+ postgresql.TIMESTAMP(),
292
+ autoincrement=False,
293
+ nullable=True,
294
+ ),
295
+ sa.ForeignKeyConstraint(
296
+ ["order_id"], ["orders.id"], name="payments_order_id_fkey"
297
+ ),
298
+ sa.PrimaryKeyConstraint("id", name="payments_pkey"),
299
+ )
300
+ op.create_index("ix_payments_id", "payments", ["id"], unique=False)
301
+ # ### end Alembic commands ###
alembic/versions/20250420_0229_ed51e0787532_add_is_active_column_to_users.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """add_is_active_column_to_users
2
+
3
+ Revision ID: ed51e0787532
4
+ Revises: 66af49b5df72
5
+ Create Date: 2025-04-20 02:29:25.813846+00:00
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "ed51e0787532"
17
+ down_revision: Union[str, None] = "66af49b5df72"
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ # Add is_active column with a default value of True
24
+ op.add_column('users', sa.Column('is_active', sa.Boolean(), nullable=False, server_default='true'))
25
+
26
+
27
+ def downgrade() -> None:
28
+ # Remove is_active column
29
+ op.drop_column('users', 'is_active')
alembic/versions/20250420_0239_c1f5d2c5c528_merge_heads.py ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """merge_heads
2
+
3
+ Revision ID: c1f5d2c5c528
4
+ Revises: 4f8a9c3d1e83
5
+ Create Date: 2025-04-20 02:39:30.652617+00:00
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+ from sqlalchemy.dialects import postgresql
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "c1f5d2c5c528"
17
+ down_revision: Union[str, None] = "4f8a9c3d1e83"
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.drop_index("ix_categories_id", table_name="categories")
25
+ op.drop_index("ix_categories_name", table_name="categories")
26
+ op.drop_table("categories")
27
+ op.drop_index("ix_payments_id", table_name="payments")
28
+ op.drop_table("payments")
29
+ op.drop_index("ix_menu_items_id", table_name="menu_items")
30
+ op.drop_index("ix_menu_items_name", table_name="menu_items")
31
+ op.drop_table("menu_items")
32
+ op.add_column(
33
+ "order_items", sa.Column("product_id", sa.Integer(), nullable=False)
34
+ )
35
+ op.add_column(
36
+ "order_items", sa.Column("price", sa.Float(), nullable=False)
37
+ )
38
+ op.alter_column(
39
+ "order_items", "order_id", existing_type=sa.INTEGER(), nullable=False
40
+ )
41
+ op.alter_column(
42
+ "order_items", "quantity", existing_type=sa.INTEGER(), nullable=False
43
+ )
44
+ op.drop_index("ix_order_items_id", table_name="order_items")
45
+ op.drop_constraint(
46
+ "order_items_menu_item_id_fkey", "order_items", type_="foreignkey"
47
+ )
48
+ op.create_foreign_key(
49
+ None, "order_items", "products", ["product_id"], ["id"]
50
+ )
51
+ op.drop_column("order_items", "menu_item_id")
52
+ op.drop_column("order_items", "unit_price")
53
+ op.add_column(
54
+ "orders", sa.Column("customer_id", sa.Integer(), nullable=False)
55
+ )
56
+ op.add_column(
57
+ "orders", sa.Column("branch_id", sa.Integer(), nullable=False)
58
+ )
59
+ op.add_column(
60
+ "orders", sa.Column("updated_at", sa.DateTime(), nullable=False)
61
+ )
62
+ op.alter_column(
63
+ "orders",
64
+ "total_amount",
65
+ existing_type=sa.DOUBLE_PRECISION(precision=53),
66
+ nullable=False,
67
+ )
68
+ op.alter_column(
69
+ "orders", "status", existing_type=sa.VARCHAR(), nullable=False
70
+ )
71
+ op.alter_column(
72
+ "orders",
73
+ "created_at",
74
+ existing_type=postgresql.TIMESTAMP(),
75
+ nullable=False,
76
+ )
77
+ op.drop_index("ix_orders_id", table_name="orders")
78
+ op.drop_constraint("orders_user_id_fkey", "orders", type_="foreignkey")
79
+ op.create_foreign_key(None, "orders", "branches", ["branch_id"], ["id"])
80
+ op.create_foreign_key(None, "orders", "users", ["customer_id"], ["id"])
81
+ op.drop_column("orders", "user_id")
82
+ op.add_column("users", sa.Column("branch_id", sa.Integer(), nullable=True))
83
+ op.alter_column(
84
+ "users", "email", existing_type=sa.VARCHAR(), nullable=False
85
+ )
86
+ op.alter_column(
87
+ "users",
88
+ "username",
89
+ existing_type=sa.TEXT(),
90
+ type_=sa.String(),
91
+ nullable=False,
92
+ )
93
+ op.alter_column(
94
+ "users", "full_name", existing_type=sa.VARCHAR(), nullable=False
95
+ )
96
+ op.alter_column(
97
+ "users", "hashed_password", existing_type=sa.VARCHAR(), nullable=False
98
+ )
99
+ op.alter_column(
100
+ "users",
101
+ "created_at",
102
+ existing_type=postgresql.TIMESTAMP(),
103
+ nullable=False,
104
+ )
105
+ op.drop_index("ix_users_id", table_name="users")
106
+ op.create_index(
107
+ op.f("ix_users_username"), "users", ["username"], unique=True
108
+ )
109
+ op.create_foreign_key(None, "users", "branches", ["branch_id"], ["id"])
110
+ op.drop_column("users", "role")
111
+ # ### end Alembic commands ###
112
+
113
+
114
+ def downgrade() -> None:
115
+ # ### commands auto generated by Alembic - please adjust! ###
116
+ op.add_column(
117
+ "users",
118
+ sa.Column("role", sa.VARCHAR(), autoincrement=False, nullable=True),
119
+ )
120
+ op.drop_constraint(None, "users", type_="foreignkey")
121
+ op.drop_index(op.f("ix_users_username"), table_name="users")
122
+ op.create_index("ix_users_id", "users", ["id"], unique=False)
123
+ op.alter_column(
124
+ "users",
125
+ "created_at",
126
+ existing_type=postgresql.TIMESTAMP(),
127
+ nullable=True,
128
+ )
129
+ op.alter_column(
130
+ "users", "hashed_password", existing_type=sa.VARCHAR(), nullable=True
131
+ )
132
+ op.alter_column(
133
+ "users", "full_name", existing_type=sa.VARCHAR(), nullable=True
134
+ )
135
+ op.alter_column(
136
+ "users",
137
+ "username",
138
+ existing_type=sa.String(),
139
+ type_=sa.TEXT(),
140
+ nullable=True,
141
+ )
142
+ op.alter_column(
143
+ "users", "email", existing_type=sa.VARCHAR(), nullable=True
144
+ )
145
+ op.drop_column("users", "branch_id")
146
+ op.add_column(
147
+ "orders",
148
+ sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True),
149
+ )
150
+ op.drop_constraint(None, "orders", type_="foreignkey")
151
+ op.drop_constraint(None, "orders", type_="foreignkey")
152
+ op.create_foreign_key(
153
+ "orders_user_id_fkey", "orders", "users", ["user_id"], ["id"]
154
+ )
155
+ op.create_index("ix_orders_id", "orders", ["id"], unique=False)
156
+ op.alter_column(
157
+ "orders",
158
+ "created_at",
159
+ existing_type=postgresql.TIMESTAMP(),
160
+ nullable=True,
161
+ )
162
+ op.alter_column(
163
+ "orders", "status", existing_type=sa.VARCHAR(), nullable=True
164
+ )
165
+ op.alter_column(
166
+ "orders",
167
+ "total_amount",
168
+ existing_type=sa.DOUBLE_PRECISION(precision=53),
169
+ nullable=True,
170
+ )
171
+ op.drop_column("orders", "updated_at")
172
+ op.drop_column("orders", "branch_id")
173
+ op.drop_column("orders", "customer_id")
174
+ op.add_column(
175
+ "order_items",
176
+ sa.Column(
177
+ "unit_price",
178
+ sa.DOUBLE_PRECISION(precision=53),
179
+ autoincrement=False,
180
+ nullable=True,
181
+ ),
182
+ )
183
+ op.add_column(
184
+ "order_items",
185
+ sa.Column(
186
+ "menu_item_id", sa.INTEGER(), autoincrement=False, nullable=True
187
+ ),
188
+ )
189
+ op.drop_constraint(None, "order_items", type_="foreignkey")
190
+ op.create_foreign_key(
191
+ "order_items_menu_item_id_fkey",
192
+ "order_items",
193
+ "menu_items",
194
+ ["menu_item_id"],
195
+ ["id"],
196
+ )
197
+ op.create_index("ix_order_items_id", "order_items", ["id"], unique=False)
198
+ op.alter_column(
199
+ "order_items", "quantity", existing_type=sa.INTEGER(), nullable=True
200
+ )
201
+ op.alter_column(
202
+ "order_items", "order_id", existing_type=sa.INTEGER(), nullable=True
203
+ )
204
+ op.drop_column("order_items", "price")
205
+ op.drop_column("order_items", "product_id")
206
+ op.create_table(
207
+ "menu_items",
208
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
209
+ sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
210
+ sa.Column(
211
+ "description", sa.VARCHAR(), autoincrement=False, nullable=True
212
+ ),
213
+ sa.Column(
214
+ "price",
215
+ sa.DOUBLE_PRECISION(precision=53),
216
+ autoincrement=False,
217
+ nullable=True,
218
+ ),
219
+ sa.Column(
220
+ "category_id", sa.INTEGER(), autoincrement=False, nullable=True
221
+ ),
222
+ sa.Column(
223
+ "image_url", sa.VARCHAR(), autoincrement=False, nullable=True
224
+ ),
225
+ sa.Column(
226
+ "is_available", sa.BOOLEAN(), autoincrement=False, nullable=True
227
+ ),
228
+ sa.Column(
229
+ "allergens",
230
+ postgresql.JSON(astext_type=sa.Text()),
231
+ autoincrement=False,
232
+ nullable=True,
233
+ ),
234
+ sa.Column(
235
+ "preparation_time",
236
+ sa.INTEGER(),
237
+ autoincrement=False,
238
+ nullable=True,
239
+ ),
240
+ sa.ForeignKeyConstraint(
241
+ ["category_id"],
242
+ ["categories.id"],
243
+ name="menu_items_category_id_fkey",
244
+ ),
245
+ sa.PrimaryKeyConstraint("id", name="menu_items_pkey"),
246
+ )
247
+ op.create_index("ix_menu_items_name", "menu_items", ["name"], unique=False)
248
+ op.create_index("ix_menu_items_id", "menu_items", ["id"], unique=False)
249
+ op.create_table(
250
+ "payments",
251
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
252
+ sa.Column(
253
+ "order_id", sa.INTEGER(), autoincrement=False, nullable=True
254
+ ),
255
+ sa.Column(
256
+ "amount",
257
+ sa.DOUBLE_PRECISION(precision=53),
258
+ autoincrement=False,
259
+ nullable=True,
260
+ ),
261
+ sa.Column("method", sa.VARCHAR(), autoincrement=False, nullable=True),
262
+ sa.Column("status", sa.VARCHAR(), autoincrement=False, nullable=True),
263
+ sa.Column(
264
+ "transaction_id", sa.VARCHAR(), autoincrement=False, nullable=True
265
+ ),
266
+ sa.Column(
267
+ "created_at",
268
+ postgresql.TIMESTAMP(),
269
+ autoincrement=False,
270
+ nullable=True,
271
+ ),
272
+ sa.ForeignKeyConstraint(
273
+ ["order_id"], ["orders.id"], name="payments_order_id_fkey"
274
+ ),
275
+ sa.PrimaryKeyConstraint("id", name="payments_pkey"),
276
+ )
277
+ op.create_index("ix_payments_id", "payments", ["id"], unique=False)
278
+ op.create_table(
279
+ "categories",
280
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
281
+ sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
282
+ sa.Column(
283
+ "type",
284
+ postgresql.ENUM(
285
+ "SOUPS",
286
+ "SWALLOW",
287
+ "RICE_DISHES",
288
+ "PROTEINS",
289
+ "SMALL_CHOPS",
290
+ "PEPPER_SOUP",
291
+ "SIDES",
292
+ "DRINKS",
293
+ name="categorytype",
294
+ ),
295
+ autoincrement=False,
296
+ nullable=True,
297
+ ),
298
+ sa.Column(
299
+ "description", sa.VARCHAR(), autoincrement=False, nullable=True
300
+ ),
301
+ sa.PrimaryKeyConstraint("id", name="categories_pkey"),
302
+ )
303
+ op.create_index("ix_categories_name", "categories", ["name"], unique=False)
304
+ op.create_index("ix_categories_id", "categories", ["id"], unique=False)
305
+ # ### end Alembic commands ###
alembic/versions/20250420_0241_20250420_0342_add_branch_id_add_branch_id_column_to_users.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """add_branch_id_column_to_users
2
+
3
+ Revision ID: 20250420_0342_add_branch_id
4
+ Revises: c1f5d2c5c528
5
+ Create Date: 2025-04-20 02:41:49.903046+00:00
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = "20250420_0342_add_branch_id"
16
+ down_revision: Union[str, None] = "c1f5d2c5c528"
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ # Add branch_id column as nullable since it's optional in the model
23
+ op.add_column('users', sa.Column('branch_id', sa.Integer(), nullable=True))
24
+ op.create_foreign_key(
25
+ 'fk_users_branch_id_branches',
26
+ 'users',
27
+ 'branches',
28
+ ['branch_id'],
29
+ ['id']
30
+ )
31
+
32
+
33
+ def downgrade() -> None:
34
+ op.drop_constraint('fk_users_branch_id_branches', 'users', type_='foreignkey')
35
+ op.drop_column('users', 'branch_id')
alembic/versions/20250420_0331_4f8a9c3d1e83_add_is_superuser_column_to_users.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """add_is_superuser_column_to_users
2
+
3
+ Revision ID: 4f8a9c3d1e83
4
+ Revises: ed51e0787532
5
+ Create Date: 2025-04-20 03:31:42.177026+00:00
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = "4f8a9c3d1e83"
16
+ down_revision: Union[str, None] = "ed51e0787532"
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ # Add is_superuser column with a default value of False
23
+ op.add_column('users', sa.Column('is_superuser', sa.Boolean(), nullable=False, server_default='false'))
24
+
25
+
26
+ def downgrade() -> None:
27
+ # Remove is_superuser column
28
+ op.drop_column('users', 'is_superuser')
alembic/versions/20250427_1200_add_staff_analytics_tables.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """add_staff_analytics_tables
2
+
3
+ Revision ID: 20250427_1200
4
+ Revises: 20250420_0342_add_branch_id
5
+ Create Date: 2025-04-27 12:00:00.000000
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+ from alembic import op
10
+ import sqlalchemy as sa
11
+ from sqlalchemy.dialects import postgresql
12
+
13
+ # revision identifiers, used by Alembic.
14
+ revision: str = '20250427_1200'
15
+ down_revision: Union[str, None] = '20250420_0342_add_branch_id'
16
+ branch_labels: Union[str, Sequence[str], None] = None
17
+ depends_on: Union[str, Sequence[str], None] = None
18
+
19
+ def upgrade() -> None:
20
+ # Create activity_type enum
21
+ op.execute("CREATE TYPE activity_type AS ENUM ('login', 'logout', 'sale', 'void', 'refund', 'inventory', 'customer_service')")
22
+
23
+ # Create staff_activities table
24
+ op.create_table(
25
+ 'staff_activities',
26
+ sa.Column('id', sa.Integer(), nullable=False),
27
+ sa.Column('user_id', sa.Integer(), nullable=False),
28
+ sa.Column('branch_id', sa.Integer(), nullable=False),
29
+ sa.Column('activity_type', sa.String(), nullable=False),
30
+ sa.Column('details', postgresql.JSONB(), nullable=False),
31
+ sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.text('now()')),
32
+ sa.Column('duration', sa.Float(), nullable=True),
33
+ sa.Column('performance_score', sa.Float(), nullable=True),
34
+ sa.ForeignKeyConstraint(['branch_id'], ['branches.id'], ),
35
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
36
+ sa.PrimaryKeyConstraint('id')
37
+ )
38
+ op.create_index('ix_staff_activities_created_at', 'staff_activities', ['created_at'])
39
+ op.create_index('ix_staff_activities_user_id', 'staff_activities', ['user_id'])
40
+ op.create_index('ix_staff_activities_branch_id', 'staff_activities', ['branch_id'])
41
+ op.create_index('ix_staff_activities_activity_type', 'staff_activities', ['activity_type'])
42
+
43
+ # Create performance_metrics table
44
+ op.create_table(
45
+ 'performance_metrics',
46
+ sa.Column('id', sa.Integer(), nullable=False),
47
+ sa.Column('user_id', sa.Integer(), nullable=False),
48
+ sa.Column('branch_id', sa.Integer(), nullable=False),
49
+ sa.Column('metric_date', sa.DateTime(), nullable=False),
50
+ sa.Column('total_sales', sa.Float(), nullable=False, server_default='0'),
51
+ sa.Column('transaction_count', sa.Integer(), nullable=False, server_default='0'),
52
+ sa.Column('average_transaction_value', sa.Float(), nullable=False, server_default='0'),
53
+ sa.Column('void_count', sa.Integer(), nullable=False, server_default='0'),
54
+ sa.Column('customer_interaction_count', sa.Integer(), nullable=False, server_default='0'),
55
+ sa.Column('login_time', sa.Float(), nullable=False, server_default='0'),
56
+ sa.Column('efficiency_score', sa.Float(), nullable=False, server_default='0'),
57
+ sa.ForeignKeyConstraint(['branch_id'], ['branches.id'], ),
58
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
59
+ sa.PrimaryKeyConstraint('id')
60
+ )
61
+ op.create_index('ix_performance_metrics_metric_date', 'performance_metrics', ['metric_date'])
62
+ op.create_index('ix_performance_metrics_user_id', 'performance_metrics', ['user_id'])
63
+ op.create_index('ix_performance_metrics_branch_id', 'performance_metrics', ['branch_id'])
64
+ op.create_unique_constraint(
65
+ 'uq_performance_metrics_user_date',
66
+ 'performance_metrics',
67
+ ['user_id', 'metric_date']
68
+ )
69
+
70
+ def downgrade() -> None:
71
+ op.drop_table('performance_metrics')
72
+ op.drop_table('staff_activities')
73
+ op.execute("DROP TYPE activity_type")
alembic/versions/20250430_1313_f04308300ffd_add_brands_table_and_relationship.py ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """add_brands_table_and_relationship
2
+
3
+ Revision ID: f04308300ffd
4
+ Revises: 20250427_1200
5
+ Create Date: 2025-04-30 13:13:16.326234+00:00
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+ from sqlalchemy.dialects import postgresql
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "f04308300ffd"
17
+ down_revision: Union[str, None] = "20250427_1200"
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ op.create_table(
25
+ "brands",
26
+ sa.Column("id", sa.Integer(), nullable=False),
27
+ sa.Column("name", sa.String(), nullable=False),
28
+ sa.Column("category", sa.String(), nullable=False),
29
+ sa.Column("established_date", sa.DateTime(), nullable=False),
30
+ sa.Column("is_active", sa.Boolean(), nullable=False),
31
+ sa.Column("created_at", sa.DateTime(), nullable=False),
32
+ sa.Column("updated_at", sa.DateTime(), nullable=False),
33
+ sa.PrimaryKeyConstraint("id"),
34
+ )
35
+ op.create_index(op.f("ix_brands_name"), "brands", ["name"], unique=True)
36
+
37
+ # Drop payments_id index if it exists
38
+ conn = op.get_bind()
39
+ inspector = sa.inspect(conn)
40
+ if 'payments' in inspector.get_table_names():
41
+ for idx in inspector.get_indexes('payments'):
42
+ if idx['name'] == 'ix_payments_id':
43
+ op.drop_index("ix_payments_id", table_name="payments")
44
+ break
45
+
46
+ # Drop tables if they exist
47
+ if 'payments' in inspector.get_table_names():
48
+ op.drop_table("payments")
49
+ if 'categories' in inspector.get_table_names():
50
+ op.drop_index("ix_categories_id", table_name="categories")
51
+ op.drop_index("ix_categories_name", table_name="categories")
52
+ op.drop_table("categories")
53
+ op.drop_index("ix_menu_items_id", table_name="menu_items")
54
+ op.drop_index("ix_menu_items_name", table_name="menu_items")
55
+ op.drop_table("menu_items")
56
+ op.add_column(
57
+ "order_items", sa.Column("product_id", sa.Integer(), nullable=False)
58
+ )
59
+ op.add_column(
60
+ "order_items", sa.Column("price", sa.Float(), nullable=False)
61
+ )
62
+ op.alter_column(
63
+ "order_items", "order_id", existing_type=sa.INTEGER(), nullable=False
64
+ )
65
+ op.alter_column(
66
+ "order_items", "quantity", existing_type=sa.INTEGER(), nullable=False
67
+ )
68
+ op.drop_index("ix_order_items_id", table_name="order_items")
69
+ op.drop_constraint(
70
+ "order_items_menu_item_id_fkey", "order_items", type_="foreignkey"
71
+ )
72
+ op.create_foreign_key(
73
+ None, "order_items", "products", ["product_id"], ["id"]
74
+ )
75
+ op.drop_column("order_items", "menu_item_id")
76
+ op.drop_column("order_items", "unit_price")
77
+ op.add_column(
78
+ "orders", sa.Column("customer_id", sa.Integer(), nullable=False)
79
+ )
80
+ op.add_column(
81
+ "orders", sa.Column("branch_id", sa.Integer(), nullable=False)
82
+ )
83
+ op.add_column(
84
+ "orders", sa.Column("updated_at", sa.DateTime(), nullable=False)
85
+ )
86
+ op.alter_column(
87
+ "orders",
88
+ "total_amount",
89
+ existing_type=sa.DOUBLE_PRECISION(precision=53),
90
+ nullable=False,
91
+ )
92
+ op.alter_column(
93
+ "orders", "status", existing_type=sa.VARCHAR(), nullable=False
94
+ )
95
+ op.alter_column(
96
+ "orders",
97
+ "created_at",
98
+ existing_type=postgresql.TIMESTAMP(),
99
+ nullable=False,
100
+ )
101
+ op.drop_index("ix_orders_id", table_name="orders")
102
+ op.drop_constraint("orders_user_id_fkey", "orders", type_="foreignkey")
103
+ op.create_foreign_key(None, "orders", "branches", ["branch_id"], ["id"])
104
+ op.create_foreign_key(None, "orders", "users", ["customer_id"], ["id"])
105
+ op.drop_column("orders", "user_id")
106
+ op.drop_index(
107
+ "ix_performance_metrics_branch_id", table_name="performance_metrics"
108
+ )
109
+ op.drop_index(
110
+ "ix_performance_metrics_metric_date", table_name="performance_metrics"
111
+ )
112
+ op.drop_index(
113
+ "ix_performance_metrics_user_id", table_name="performance_metrics"
114
+ )
115
+ op.drop_constraint(
116
+ "uq_performance_metrics_user_date",
117
+ "performance_metrics",
118
+ type_="unique",
119
+ )
120
+ op.add_column(
121
+ "products", sa.Column("brand_id", sa.Integer(), nullable=True)
122
+ )
123
+ op.create_foreign_key(None, "products", "brands", ["brand_id"], ["id"])
124
+ op.add_column(
125
+ "sessions", sa.Column("iteration_active", sa.Boolean(), nullable=False)
126
+ )
127
+ op.alter_column(
128
+ "staff_activities",
129
+ "details",
130
+ existing_type=postgresql.JSONB(astext_type=sa.Text()),
131
+ type_=sa.JSON(),
132
+ existing_nullable=False,
133
+ )
134
+ op.drop_index(
135
+ "ix_staff_activities_activity_type", table_name="staff_activities"
136
+ )
137
+ op.drop_index(
138
+ "ix_staff_activities_branch_id", table_name="staff_activities"
139
+ )
140
+ op.drop_index(
141
+ "ix_staff_activities_created_at", table_name="staff_activities"
142
+ )
143
+ op.drop_index("ix_staff_activities_user_id", table_name="staff_activities")
144
+ op.alter_column(
145
+ "users", "email", existing_type=sa.VARCHAR(), nullable=False
146
+ )
147
+ op.alter_column(
148
+ "users",
149
+ "username",
150
+ existing_type=sa.TEXT(),
151
+ type_=sa.String(),
152
+ nullable=False,
153
+ )
154
+ op.alter_column(
155
+ "users", "full_name", existing_type=sa.VARCHAR(), nullable=False
156
+ )
157
+ op.alter_column(
158
+ "users", "hashed_password", existing_type=sa.VARCHAR(), nullable=False
159
+ )
160
+ op.alter_column(
161
+ "users",
162
+ "created_at",
163
+ existing_type=postgresql.TIMESTAMP(),
164
+ nullable=False,
165
+ )
166
+ op.drop_index("ix_users_id", table_name="users")
167
+ op.create_index(
168
+ op.f("ix_users_username"), "users", ["username"], unique=True
169
+ )
170
+ op.drop_column("users", "role")
171
+ # ### end Alembic commands ###
172
+
173
+
174
+ def downgrade() -> None:
175
+ # ### commands auto generated by Alembic - please adjust! ###
176
+ op.add_column(
177
+ "users",
178
+ sa.Column("role", sa.VARCHAR(), autoincrement=False, nullable=True),
179
+ )
180
+ op.drop_index(op.f("ix_users_username"), table_name="users")
181
+ op.create_index("ix_users_id", "users", ["id"], unique=False)
182
+ op.alter_column(
183
+ "users",
184
+ "created_at",
185
+ existing_type=postgresql.TIMESTAMP(),
186
+ nullable=True,
187
+ )
188
+ op.alter_column(
189
+ "users", "hashed_password", existing_type=sa.VARCHAR(), nullable=True
190
+ )
191
+ op.alter_column(
192
+ "users", "full_name", existing_type=sa.VARCHAR(), nullable=True
193
+ )
194
+ op.alter_column(
195
+ "users",
196
+ "username",
197
+ existing_type=sa.String(),
198
+ type_=sa.TEXT(),
199
+ nullable=True,
200
+ )
201
+ op.alter_column(
202
+ "users", "email", existing_type=sa.VARCHAR(), nullable=True
203
+ )
204
+ op.create_index(
205
+ "ix_staff_activities_user_id",
206
+ "staff_activities",
207
+ ["user_id"],
208
+ unique=False,
209
+ )
210
+ op.create_index(
211
+ "ix_staff_activities_created_at",
212
+ "staff_activities",
213
+ ["created_at"],
214
+ unique=False,
215
+ )
216
+ op.create_index(
217
+ "ix_staff_activities_branch_id",
218
+ "staff_activities",
219
+ ["branch_id"],
220
+ unique=False,
221
+ )
222
+ op.create_index(
223
+ "ix_staff_activities_activity_type",
224
+ "staff_activities",
225
+ ["activity_type"],
226
+ unique=False,
227
+ )
228
+ op.alter_column(
229
+ "staff_activities",
230
+ "details",
231
+ existing_type=sa.JSON(),
232
+ type_=postgresql.JSONB(astext_type=sa.Text()),
233
+ existing_nullable=False,
234
+ )
235
+ op.drop_column("sessions", "iteration_active")
236
+ op.drop_constraint(None, "products", type_="foreignkey")
237
+ op.drop_column("products", "brand_id")
238
+ op.create_unique_constraint(
239
+ "uq_performance_metrics_user_date",
240
+ "performance_metrics",
241
+ ["user_id", "metric_date"],
242
+ )
243
+ op.create_index(
244
+ "ix_performance_metrics_user_id",
245
+ "performance_metrics",
246
+ ["user_id"],
247
+ unique=False,
248
+ )
249
+ op.create_index(
250
+ "ix_performance_metrics_metric_date",
251
+ "performance_metrics",
252
+ ["metric_date"],
253
+ unique=False,
254
+ )
255
+ op.create_index(
256
+ "ix_performance_metrics_branch_id",
257
+ "performance_metrics",
258
+ ["branch_id"],
259
+ unique=False,
260
+ )
261
+ op.add_column(
262
+ "orders",
263
+ sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=True),
264
+ )
265
+ op.drop_constraint(None, "orders", type_="foreignkey")
266
+ op.drop_constraint(None, "orders", type_="foreignkey")
267
+ op.create_foreign_key(
268
+ "orders_user_id_fkey", "orders", "users", ["user_id"], ["id"]
269
+ )
270
+ op.create_index("ix_orders_id", "orders", ["id"], unique=False)
271
+ op.alter_column(
272
+ "orders",
273
+ "created_at",
274
+ existing_type=postgresql.TIMESTAMP(),
275
+ nullable=True,
276
+ )
277
+ op.alter_column(
278
+ "orders", "status", existing_type=sa.VARCHAR(), nullable=True
279
+ )
280
+ op.alter_column(
281
+ "orders",
282
+ "total_amount",
283
+ existing_type=sa.DOUBLE_PRECISION(precision=53),
284
+ nullable=True,
285
+ )
286
+ op.drop_column("orders", "updated_at")
287
+ op.drop_column("orders", "branch_id")
288
+ op.drop_column("orders", "customer_id")
289
+ op.add_column(
290
+ "order_items",
291
+ sa.Column(
292
+ "unit_price",
293
+ sa.DOUBLE_PRECISION(precision=53),
294
+ autoincrement=False,
295
+ nullable=True,
296
+ ),
297
+ )
298
+ op.add_column(
299
+ "order_items",
300
+ sa.Column(
301
+ "menu_item_id", sa.INTEGER(), autoincrement=False, nullable=True
302
+ ),
303
+ )
304
+ op.drop_constraint(None, "order_items", type_="foreignkey")
305
+ op.create_foreign_key(
306
+ "order_items_menu_item_id_fkey",
307
+ "order_items",
308
+ "menu_items",
309
+ ["menu_item_id"],
310
+ ["id"],
311
+ )
312
+ op.create_index("ix_order_items_id", "order_items", ["id"], unique=False)
313
+ op.alter_column(
314
+ "order_items", "quantity", existing_type=sa.INTEGER(), nullable=True
315
+ )
316
+ op.alter_column(
317
+ "order_items", "order_id", existing_type=sa.INTEGER(), nullable=True
318
+ )
319
+ op.drop_column("order_items", "price")
320
+ op.drop_column("order_items", "product_id")
321
+ op.create_table(
322
+ "menu_items",
323
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
324
+ sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
325
+ sa.Column(
326
+ "description", sa.VARCHAR(), autoincrement=False, nullable=True
327
+ ),
328
+ sa.Column(
329
+ "price",
330
+ sa.DOUBLE_PRECISION(precision=53),
331
+ autoincrement=False,
332
+ nullable=True,
333
+ ),
334
+ sa.Column(
335
+ "category_id", sa.INTEGER(), autoincrement=False, nullable=True
336
+ ),
337
+ sa.Column(
338
+ "image_url", sa.VARCHAR(), autoincrement=False, nullable=True
339
+ ),
340
+ sa.Column(
341
+ "is_available", sa.BOOLEAN(), autoincrement=False, nullable=True
342
+ ),
343
+ sa.Column(
344
+ "allergens",
345
+ postgresql.JSON(astext_type=sa.Text()),
346
+ autoincrement=False,
347
+ nullable=True,
348
+ ),
349
+ sa.Column(
350
+ "preparation_time",
351
+ sa.INTEGER(),
352
+ autoincrement=False,
353
+ nullable=True,
354
+ ),
355
+ sa.ForeignKeyConstraint(
356
+ ["category_id"],
357
+ ["categories.id"],
358
+ name="menu_items_category_id_fkey",
359
+ ),
360
+ sa.PrimaryKeyConstraint("id", name="menu_items_pkey"),
361
+ )
362
+ op.create_index("ix_menu_items_name", "menu_items", ["name"], unique=False)
363
+ op.create_index("ix_menu_items_id", "menu_items", ["id"], unique=False)
364
+ op.create_table(
365
+ "categories",
366
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
367
+ sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
368
+ sa.Column(
369
+ "type",
370
+ postgresql.ENUM(
371
+ "SOUPS",
372
+ "SWALLOW",
373
+ "RICE_DISHES",
374
+ "PROTEINS",
375
+ "SMALL_CHOPS",
376
+ "PEPPER_SOUP",
377
+ "SIDES",
378
+ "DRINKS",
379
+ name="categorytype",
380
+ ),
381
+ autoincrement=False,
382
+ nullable=True,
383
+ ),
384
+ sa.Column(
385
+ "description", sa.VARCHAR(), autoincrement=False, nullable=True
386
+ ),
387
+ sa.PrimaryKeyConstraint("id", name="categories_pkey"),
388
+ )
389
+ op.create_index("ix_categories_name", "categories", ["name"], unique=False)
390
+ op.create_index("ix_categories_id", "categories", ["id"], unique=False)
391
+ op.create_table(
392
+ "payments",
393
+ sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
394
+ sa.Column(
395
+ "order_id", sa.INTEGER(), autoincrement=False, nullable=True
396
+ ),
397
+ sa.Column(
398
+ "amount",
399
+ sa.DOUBLE_PRECISION(precision=53),
400
+ autoincrement=False,
401
+ nullable=True,
402
+ ),
403
+ sa.Column("method", sa.VARCHAR(), autoincrement=False, nullable=True),
404
+ sa.Column("status", sa.VARCHAR(), autoincrement=False, nullable=True),
405
+ sa.Column(
406
+ "transaction_id", sa.VARCHAR(), autoincrement=False, nullable=True
407
+ ),
408
+ sa.Column(
409
+ "created_at",
410
+ postgresql.TIMESTAMP(),
411
+ autoincrement=False,
412
+ nullable=True,
413
+ ),
414
+ sa.ForeignKeyConstraint(
415
+ ["order_id"], ["orders.id"], name="payments_order_id_fkey"
416
+ ),
417
+ sa.PrimaryKeyConstraint("id", name="payments_pkey"),
418
+ )
419
+ op.create_index("ix_payments_id", "payments", ["id"], unique=False)
420
+ op.drop_index(op.f("ix_brands_name"), table_name="brands")
421
+ op.drop_table("brands")
422
+ # ### end Alembic commands ###
alembic/versions/__pycache__/20250419_1337_66af49b5df72_add_username_column_to_users_table.cpython-312.pyc ADDED
Binary file (12.9 kB). View file
 
alembic/versions/__pycache__/20250420_0229_ed51e0787532_add_is_active_column_to_users.cpython-312.pyc ADDED
Binary file (1.36 kB). View file
 
alembic/versions/__pycache__/20250420_0235_01a60c7642b2_add_is_superuser_column_to_users.cpython-312.pyc ADDED
Binary file (1.03 kB). View file
 
alembic/versions/__pycache__/20250420_0239_c1f5d2c5c528_merge_heads.cpython-312.pyc ADDED
Binary file (12.6 kB). View file
 
alembic/versions/__pycache__/20250420_0241_20250420_0342_add_branch_id_add_branch_id_column_to_users.cpython-312.pyc ADDED
Binary file (1.63 kB). View file
 
alembic/versions/__pycache__/20250420_0331_4f8a9c3d1e83_add_is_superuser_column_to_users.cpython-312.pyc ADDED
Binary file (1.37 kB). View file
 
alembic/versions/__pycache__/20250427_1200_add_staff_analytics_tables.cpython-312.pyc ADDED
Binary file (5.38 kB). View file
 
alembic/versions/__pycache__/20250430_1313_f04308300ffd_add_brands_table_and_relationship.cpython-312.pyc ADDED
Binary file (16.7 kB). View file