lavkach3
1079 строк · 71.9 Кб
1"""init
2
3Revision ID: c91e663a5810
4Revises:
5Create Date: 2024-09-06 10:34:52.401816
6
7"""
8from alembic import op
9import sqlalchemy as sa
10import sqlalchemy_utils
11from sqlalchemy.dialects import postgresql
12
13# revision identifiers, used by Alembic.
14revision = 'c91e663a5810'
15down_revision = None
16branch_labels = None
17depends_on = None
18
19
20def upgrade():
21# ### commands auto generated by Alembic - please adjust! ###
22op.create_table('company',
23sa.Column('id', sa.Uuid(), nullable=False),
24sa.Column('title', sa.String(), nullable=False),
25sa.Column('external_number', sa.String(), nullable=True),
26sa.Column('country', sqlalchemy_utils.types.country.CountryType(length=2),
27nullable=False),
28sa.Column('locale', sqlalchemy_utils.types.locale.LocaleType(), nullable=False),
29sa.Column('currency', sqlalchemy_utils.types.currency.CurrencyType(length=3),
30nullable=False),
31sa.Column('created_at', sa.DateTime(),
32server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
33nullable=False),
34sa.Column('updated_at', sa.DateTime(),
35server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
36nullable=True),
37sa.Column('lsn', sa.BigInteger(), nullable=True),
38sa.PrimaryKeyConstraint('id'),
39sa.UniqueConstraint('external_number')
40)
41op.create_index(op.f('ix_company_id'), 'company', ['id'], unique=False)
42op.create_index(op.f('ix_company_lsn'), 'company', ['lsn'], unique=False)
43op.create_index(op.f('ix_company_title'), 'company', ['title'], unique=False)
44op.create_table('bus',
45sa.Column('id', sa.Uuid(), nullable=False),
46sa.Column('cache_tag',
47sa.Enum('GET_USER_LIST', 'WS_SESSION', 'MESSAGE', 'MODEL', 'REFRESH','LOGOUT',
48name='cachetag'), nullable=False),
49sa.Column('message', sa.String(), nullable=False),
50sa.Column('status',
51sa.Enum('NEW', 'PROCESSING', 'ERROR', 'DELIVERED', name='busstatus'),
52nullable=False),
53sa.Column('lsn', sa.BigInteger(), nullable=True),
54sa.Column('company_id', sa.Uuid(), nullable=False),
55sa.Column('created_at', sa.DateTime(),
56server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
57nullable=False),
58sa.Column('updated_at', sa.DateTime(),
59server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
60nullable=True),
61sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
62sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
63sa.PrimaryKeyConstraint('id')
64)
65op.create_index(op.f('ix_bus_cache_tag'), 'bus', ['cache_tag'], unique=False)
66op.create_index(op.f('ix_bus_company_id'), 'bus', ['company_id'], unique=False)
67op.create_index(op.f('ix_bus_id'), 'bus', ['id'], unique=False)
68op.create_index(op.f('ix_bus_lsn'), 'bus', ['lsn'], unique=False)
69op.create_index(op.f('ix_bus_status'), 'bus', ['status'], unique=False)
70op.create_table('lot',
71sa.Column('id', sa.Uuid(), nullable=False),
72sa.Column('expiration_datetime', sa.DateTime(timezone=True), nullable=True),
73sa.Column('product_id', sa.Uuid(), nullable=True),
74sa.Column('external_number', sa.String(), nullable=False),
75sa.Column('partner_id', sa.Uuid(), nullable=True),
76sa.Column('lsn', sa.BigInteger(), nullable=True),
77sa.Column('company_id', sa.Uuid(), nullable=False),
78sa.Column('created_at', sa.DateTime(),
79server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
80nullable=False),
81sa.Column('updated_at', sa.DateTime(),
82server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
83nullable=True),
84sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
85sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
86sa.PrimaryKeyConstraint('id'),
87sa.UniqueConstraint('external_number'),
88sa.UniqueConstraint('external_number', 'product_id', 'partner_id',
89name='_lot_ex_pr_par_id_uc')
90)
91op.create_index(op.f('ix_lot_company_id'), 'lot', ['company_id'], unique=False)
92op.create_index(op.f('ix_lot_id'), 'lot', ['id'], unique=False)
93op.create_index(op.f('ix_lot_lsn'), 'lot', ['lsn'], unique=False)
94op.create_index(op.f('ix_lot_partner_id'), 'lot', ['partner_id'], unique=False)
95op.create_index(op.f('ix_lot_product_id'), 'lot', ['product_id'], unique=False)
96op.create_table('order_type',
97sa.Column('prefix', sa.String(), nullable=False),
98sa.Column('title', sa.String(), nullable=False),
99sa.Column('id', sa.Uuid(), nullable=False),
100sa.Column('order_class',
101sa.Enum('INCOMING', 'OUTGOING', 'INTERNAL', name='orderclass'),
102nullable=False),
103sa.Column('allowed_location_src_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
104nullable=False),
105sa.Column('exclude_location_src_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
106nullable=False),
107sa.Column('allowed_location_dest_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
108nullable=False),
109sa.Column('exclude_location_dest_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
110nullable=False),
111sa.Column('allowed_location_type_src_ids', sa.ARRAY(sa.Uuid()),
112server_default='{}', nullable=False),
113sa.Column('exclude_location_type_src_ids', sa.ARRAY(sa.Uuid()),
114server_default='{}', nullable=False),
115sa.Column('allowed_location_type_dest_ids', sa.ARRAY(sa.Uuid()),
116server_default='{}', nullable=False),
117sa.Column('exclude_location_type_dest_ids', sa.ARRAY(sa.Uuid()),
118server_default='{}', nullable=False),
119sa.Column('allowed_location_class_src_ids', sa.ARRAY(sa.String()),
120server_default='{}', nullable=False),
121sa.Column('exclude_location_class_src_ids', sa.ARRAY(sa.String()),
122server_default='{}', nullable=False),
123sa.Column('allowed_location_class_dest_ids', sa.ARRAY(sa.String()),
124server_default='{}', nullable=False),
125sa.Column('exclude_location_class_dest_ids', sa.ARRAY(sa.String()),
126server_default='{}', nullable=False),
127sa.Column('order_type_id', sa.Uuid(), nullable=True),
128sa.Column('backorder_action_type',
129sa.Enum('ASK', 'ALWAYS', 'NEVER', name='backorderaction'),
130nullable=False),
131sa.Column('store_id', sa.Uuid(), nullable=True),
132sa.Column('partner_id', sa.Uuid(), nullable=True),
133sa.Column('reservation_method',
134sa.Enum('AT_CONFIRM', 'MANUAL', 'AT_DATE', 'TIME_BEFORE_DATE',
135name='reservationmethod'), nullable=False),
136sa.Column('reservation_time_before', sa.Integer(), nullable=True),
137sa.Column('allowed_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
138nullable=False),
139sa.Column('exclude_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
140nullable=False),
141sa.Column('is_homogeneity', sa.Boolean(), nullable=False),
142sa.Column('is_allow_create_package', sa.Boolean(), nullable=False),
143sa.Column('is_can_create_order_manualy', sa.Boolean(), nullable=False),
144sa.Column('is_overdelivery', sa.Boolean(), nullable=False),
145sa.Column('barcode', sa.String(), nullable=False),
146sa.Column('strategy',
147sa.Enum('FEFO', 'FIFO', 'LIFO', 'LEFO', name='putawaystrategy'),
148nullable=False),
149sa.Column('lsn', sa.BigInteger(), nullable=True),
150sa.Column('company_id', sa.Uuid(), nullable=False),
151sa.Column('created_at', sa.DateTime(),
152server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
153nullable=False),
154sa.Column('updated_at', sa.DateTime(),
155server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
156nullable=True),
157sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
158sa.Column('created_by', sa.Uuid(), nullable=False),
159sa.Column('edited_by', sa.Uuid(), nullable=False),
160sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
161sa.ForeignKeyConstraint(['order_type_id'], ['order_type.id'],
162ondelete='CASCADE'),
163sa.PrimaryKeyConstraint('id'),
164sa.UniqueConstraint('title', 'company_id',
165name='_order_type_companyid_title_uc')
166)
167op.create_index(op.f('ix_order_type_allowed_location_class_dest_ids'), 'order_type',
168['allowed_location_class_dest_ids'], unique=False)
169op.create_index(op.f('ix_order_type_allowed_location_class_src_ids'), 'order_type',
170['allowed_location_class_src_ids'], unique=False)
171op.create_index(op.f('ix_order_type_allowed_location_dest_ids'), 'order_type',
172['allowed_location_dest_ids'], unique=False)
173op.create_index(op.f('ix_order_type_allowed_location_src_ids'), 'order_type',
174['allowed_location_src_ids'], unique=False)
175op.create_index(op.f('ix_order_type_allowed_location_type_dest_ids'), 'order_type',
176['allowed_location_type_dest_ids'], unique=False)
177op.create_index(op.f('ix_order_type_allowed_location_type_src_ids'), 'order_type',
178['allowed_location_type_src_ids'], unique=False)
179op.create_index(op.f('ix_order_type_allowed_package_ids'), 'order_type',
180['allowed_package_ids'], unique=False)
181op.create_index(op.f('ix_order_type_company_id'), 'order_type', ['company_id'], unique=False)
182op.create_index(op.f('ix_order_type_created_by'), 'order_type', ['created_by'], unique=False)
183op.create_index(op.f('ix_order_type_edited_by'), 'order_type', ['edited_by'], unique=False)
184op.create_index(op.f('ix_order_type_exclude_location_class_dest_ids'), 'order_type',
185['exclude_location_class_dest_ids'], unique=False)
186op.create_index(op.f('ix_order_type_exclude_location_class_src_ids'), 'order_type',
187['exclude_location_class_src_ids'], unique=False)
188op.create_index(op.f('ix_order_type_exclude_location_dest_ids'), 'order_type',
189['exclude_location_dest_ids'], unique=False)
190op.create_index(op.f('ix_order_type_exclude_location_src_ids'), 'order_type',
191['exclude_location_src_ids'], unique=False)
192op.create_index(op.f('ix_order_type_exclude_location_type_dest_ids'), 'order_type',
193['exclude_location_type_dest_ids'], unique=False)
194op.create_index(op.f('ix_order_type_exclude_location_type_src_ids'), 'order_type',
195['exclude_location_type_src_ids'], unique=False)
196op.create_index(op.f('ix_order_type_exclude_package_ids'), 'order_type',
197['exclude_package_ids'], unique=False)
198op.create_index(op.f('ix_order_type_id'), 'order_type', ['id'], unique=False)
199op.create_index(op.f('ix_order_type_lsn'), 'order_type', ['lsn'], unique=False)
200op.create_index(op.f('ix_order_type_partner_id'), 'order_type', ['partner_id'], unique=False)
201op.create_index(op.f('ix_order_type_prefix'), 'order_type', ['prefix'], unique=False)
202op.create_index(op.f('ix_order_type_store_id'), 'order_type', ['store_id'], unique=False)
203op.create_index(op.f('ix_order_type_title'), 'order_type', ['title'], unique=False)
204op.create_table('product_category',
205sa.Column('id', sa.Uuid(), nullable=False),
206sa.Column('external_number', sa.String(), nullable=True),
207sa.Column('title', sa.String(), nullable=False),
208sa.Column('product_category_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
209nullable=False),
210sa.Column('lsn', sa.BigInteger(), nullable=True),
211sa.Column('company_id', sa.Uuid(), nullable=False),
212sa.Column('created_at', sa.DateTime(),
213server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
214nullable=False),
215sa.Column('updated_at', sa.DateTime(),
216server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
217nullable=True),
218sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
219sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
220sa.PrimaryKeyConstraint('id'),
221sa.UniqueConstraint('external_number', 'company_id',
222name='_product_category_company_id_uc')
223)
224op.create_index(op.f('ix_product_category_company_id'), 'product_category', ['company_id'],
225unique=False)
226op.create_index(op.f('ix_product_category_id'), 'product_category', ['id'], unique=False)
227op.create_index(op.f('ix_product_category_lsn'), 'product_category', ['lsn'], unique=False)
228op.create_index(op.f('ix_product_category_product_category_ids'), 'product_category',
229['product_category_ids'], unique=False)
230op.create_index(op.f('ix_product_category_title'), 'product_category', ['title'], unique=False)
231op.create_table('product_storage_type',
232sa.Column('product_id', sa.Uuid(), nullable=False),
233sa.Column('storage_uom_id', sa.Uuid(), nullable=True),
234sa.Column('storage_image_url', sa.String(), nullable=True),
235sa.Column('allowed_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
236nullable=False),
237sa.Column('exclude_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
238nullable=False),
239sa.Column('is_homogeneity', sa.Boolean(), nullable=False),
240sa.Column('is_mix_products', sa.Boolean(), nullable=True),
241sa.Column('storage_type_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
242nullable=False),
243sa.Column('id', sa.Uuid(), nullable=False),
244sa.Column('lsn', sa.BigInteger(), nullable=True),
245sa.Column('company_id', sa.Uuid(), nullable=False),
246sa.Column('created_at', sa.DateTime(),
247server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
248nullable=False),
249sa.Column('updated_at', sa.DateTime(),
250server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
251nullable=True),
252sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
253sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
254sa.PrimaryKeyConstraint('id'),
255sa.UniqueConstraint('product_id', 'company_id',
256name='stor_type_product_company_id_uc')
257)
258op.create_index(op.f('ix_product_storage_type_allowed_package_ids'), 'product_storage_type',
259['allowed_package_ids'], unique=False)
260op.create_index(op.f('ix_product_storage_type_company_id'), 'product_storage_type',
261['company_id'], unique=False)
262op.create_index(op.f('ix_product_storage_type_exclude_package_ids'), 'product_storage_type',
263['exclude_package_ids'], unique=False)
264op.create_index(op.f('ix_product_storage_type_id'), 'product_storage_type', ['id'],
265unique=False)
266op.create_index(op.f('ix_product_storage_type_lsn'), 'product_storage_type', ['lsn'],
267unique=False)
268op.create_index(op.f('ix_product_storage_type_product_id'), 'product_storage_type',
269['product_id'], unique=False)
270op.create_table('role',
271sa.Column('id', sa.Uuid(), nullable=False),
272sa.Column('title', sa.String(), nullable=False),
273sa.Column('role_ids', sa.ARRAY(sa.Uuid()), server_default='{}', nullable=False,
274comment='Список дочерних ролей'),
275sa.Column('permission_allow_list', postgresql.ARRAY(sa.String()),
276server_default='{}', nullable=False),
277sa.Column('permission_deny_list', postgresql.ARRAY(sa.String()),
278server_default='{}', nullable=False),
279sa.Column('lsn', sa.BigInteger(), nullable=True),
280sa.Column('company_id', sa.Uuid(), nullable=False),
281sa.Column('created_at', sa.DateTime(),
282server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
283nullable=False),
284sa.Column('updated_at', sa.DateTime(),
285server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
286nullable=True),
287sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
288sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
289sa.PrimaryKeyConstraint('id'),
290sa.UniqueConstraint('title', 'company_id', name='_role_company_id_uc')
291)
292op.create_index(op.f('ix_role_company_id'), 'role', ['company_id'], unique=False)
293op.create_index(op.f('ix_role_id'), 'role', ['id'], unique=False)
294op.create_index(op.f('ix_role_lsn'), 'role', ['lsn'], unique=False)
295op.create_index(op.f('ix_role_permission_allow_list'), 'role', ['permission_allow_list'],
296unique=False)
297op.create_index(op.f('ix_role_role_ids'), 'role', ['role_ids'], unique=False)
298op.create_index(op.f('ix_role_title'), 'role', ['title'], unique=False)
299op.create_table('storage_type',
300sa.Column('id', sa.Uuid(), nullable=False),
301sa.Column('title', sa.String(), nullable=False),
302sa.Column('priority', sa.Integer(), nullable=False),
303sa.Column('location_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
304nullable=False),
305sa.Column('lsn', sa.BigInteger(), nullable=True),
306sa.Column('company_id', sa.Uuid(), nullable=False),
307sa.Column('created_at', sa.DateTime(),
308server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
309nullable=False),
310sa.Column('updated_at', sa.DateTime(),
311server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
312nullable=True),
313sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
314sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
315sa.PrimaryKeyConstraint('id')
316)
317op.create_index(op.f('ix_storage_type_company_id'), 'storage_type', ['company_id'],
318unique=False)
319op.create_index(op.f('ix_storage_type_id'), 'storage_type', ['id'], unique=False)
320op.create_index(op.f('ix_storage_type_lsn'), 'storage_type', ['lsn'], unique=False)
321op.create_table('store',
322sa.Column('id', sa.Uuid(), nullable=False),
323sa.Column('title', sa.String(), nullable=False),
324sa.Column('external_number', sa.String(), nullable=True),
325sa.Column('address', sa.String(), nullable=False),
326sa.Column('source', sa.String(), nullable=False),
327sa.Column('lsn', sa.BigInteger(), nullable=True),
328sa.Column('company_id', sa.Uuid(), nullable=False),
329sa.Column('created_at', sa.DateTime(),
330server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
331nullable=False),
332sa.Column('updated_at', sa.DateTime(),
333server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
334nullable=True),
335sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
336sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
337sa.PrimaryKeyConstraint('id'),
338sa.UniqueConstraint('external_number')
339)
340op.create_index(op.f('ix_store_company_id'), 'store', ['company_id'], unique=False)
341op.create_index(op.f('ix_store_id'), 'store', ['id'], unique=False)
342op.create_index(op.f('ix_store_lsn'), 'store', ['lsn'], unique=False)
343op.create_index(op.f('ix_store_title'), 'store', ['title'], unique=False)
344op.create_table('uom_category',
345sa.Column('id', sa.Uuid(), nullable=False),
346sa.Column('title', sa.String(), nullable=False),
347sa.Column('lsn', sa.BigInteger(), nullable=True),
348sa.Column('company_id', sa.Uuid(), nullable=False),
349sa.Column('created_at', sa.DateTime(),
350server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
351nullable=False),
352sa.Column('updated_at', sa.DateTime(),
353server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
354nullable=True),
355sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
356sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
357sa.PrimaryKeyConstraint('id')
358)
359op.create_index(op.f('ix_uom_category_company_id'), 'uom_category', ['company_id'],
360unique=False)
361op.create_index(op.f('ix_uom_category_id'), 'uom_category', ['id'], unique=False)
362op.create_index(op.f('ix_uom_category_lsn'), 'uom_category', ['lsn'], unique=False)
363op.create_index(op.f('ix_uom_category_title'), 'uom_category', ['title'], unique=False)
364op.create_table('location_type',
365sa.Column('title', sa.String(), nullable=False),
366sa.Column('store_id', sa.Uuid(), nullable=True),
367sa.Column('allowed_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
368nullable=False),
369sa.Column('exclude_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
370nullable=False),
371sa.Column('is_homogeneity', sa.Boolean(), nullable=True),
372sa.Column('strategy',
373sa.Enum('FEFO', 'FIFO', 'LIFO', 'LEFO', name='putawaystrategy'),
374nullable=True),
375sa.Column('is_can_negative', sa.Boolean(), server_default=sa.text('false'),
376nullable=True),
377sa.Column('id', sa.Uuid(), nullable=False),
378sa.Column('lsn', sa.BigInteger(), nullable=True),
379sa.Column('company_id', sa.Uuid(), nullable=False),
380sa.Column('created_at', sa.DateTime(),
381server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
382nullable=False),
383sa.Column('updated_at', sa.DateTime(),
384server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
385nullable=True),
386sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
387sa.Column('location_class',
388sa.Enum('PARTNER', 'PLACE', 'RESOURCE', 'PACKAGE', 'ZONE', 'LOST',
389'INVENTORY', 'SCRAP', 'SCRAPPED', 'BUFFER',
390name='locationclass'), nullable=False),
391sa.Column('lot_id', sa.Uuid(), nullable=True),
392sa.Column('partner_id', sa.Uuid(), nullable=True),
393sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
394sa.ForeignKeyConstraint(['lot_id'], ['lot.id'], ondelete='SET NULL'),
395sa.PrimaryKeyConstraint('id')
396)
397op.create_index(op.f('ix_location_type_allowed_package_ids'), 'location_type',
398['allowed_package_ids'], unique=False)
399op.create_index(op.f('ix_location_type_company_id'), 'location_type', ['company_id'],
400unique=False)
401op.create_index(op.f('ix_location_type_exclude_package_ids'), 'location_type',
402['exclude_package_ids'], unique=False)
403op.create_index(op.f('ix_location_type_id'), 'location_type', ['id'], unique=False)
404op.create_index(op.f('ix_location_type_is_can_negative'), 'location_type', ['is_can_negative'],
405unique=False)
406op.create_index(op.f('ix_location_type_is_homogeneity'), 'location_type', ['is_homogeneity'],
407unique=False)
408op.create_index(op.f('ix_location_type_location_class'), 'location_type', ['location_class'],
409unique=False)
410op.create_index(op.f('ix_location_type_lot_id'), 'location_type', ['lot_id'], unique=False)
411op.create_index(op.f('ix_location_type_lsn'), 'location_type', ['lsn'], unique=False)
412op.create_index(op.f('ix_location_type_partner_id'), 'location_type', ['partner_id'],
413unique=False)
414op.create_index(op.f('ix_location_type_store_id'), 'location_type', ['store_id'], unique=False)
415op.create_index(op.f('ix_location_type_title'), 'location_type', ['title'], unique=False)
416op.create_table('order',
417sa.Column('number', sa.String(), nullable=False),
418sa.Column('order_type_id', sa.Uuid(), nullable=False),
419sa.Column('order_id', sa.Uuid(), nullable=True),
420sa.Column('external_number', sa.String(), nullable=True),
421sa.Column('store_id', sa.Uuid(), nullable=False),
422sa.Column('partner_id', sa.Uuid(), nullable=True),
423sa.Column('lot_id', sa.Uuid(), nullable=True),
424sa.Column('origin_type', sa.String(), nullable=True),
425sa.Column('origin_number', sa.String(), nullable=True),
426sa.Column('planned_datetime', sa.DateTime(timezone=True), nullable=True),
427sa.Column('actual_datetime', sa.DateTime(timezone=True), nullable=True),
428sa.Column('expiration_datetime', sa.DateTime(timezone=True), nullable=True),
429sa.Column('user_ids', sa.ARRAY(sa.Uuid()), server_default='{}', nullable=False),
430sa.Column('description', sa.String(), nullable=True),
431sa.Column('status', sa.Enum('DRAFT', 'WAITING', 'CONFIRMED', 'ASSIGNED', 'DONE',
432'CANCELED', name='orderstatus'), nullable=False),
433sa.Column('id', sa.Uuid(), nullable=False),
434sa.Column('lsn', sa.BigInteger(), nullable=True),
435sa.Column('company_id', sa.Uuid(), nullable=False),
436sa.Column('created_at', sa.DateTime(),
437server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
438nullable=False),
439sa.Column('updated_at', sa.DateTime(),
440server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
441nullable=True),
442sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
443sa.Column('created_by', sa.Uuid(), nullable=False),
444sa.Column('edited_by', sa.Uuid(), nullable=False),
445sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
446sa.ForeignKeyConstraint(['lot_id'], ['lot.id'], ondelete='SET NULL'),
447sa.ForeignKeyConstraint(['order_id'], ['order.id'], ondelete='CASCADE'),
448sa.ForeignKeyConstraint(['order_type_id'], ['order_type.id'],
449ondelete='CASCADE'),
450sa.PrimaryKeyConstraint('id'),
451sa.UniqueConstraint('external_number', 'company_id',
452name='_order_companyid_external_number_uc')
453)
454op.create_index(op.f('ix_order_company_id'), 'order', ['company_id'], unique=False)
455op.create_index(op.f('ix_order_created_by'), 'order', ['created_by'], unique=False)
456op.create_index(op.f('ix_order_edited_by'), 'order', ['edited_by'], unique=False)
457op.create_index(op.f('ix_order_id'), 'order', ['id'], unique=False)
458op.create_index(op.f('ix_order_lsn'), 'order', ['lsn'], unique=False)
459op.create_index(op.f('ix_order_number'), 'order', ['number'], unique=False)
460op.create_index(op.f('ix_order_origin_number'), 'order', ['origin_number'], unique=False)
461op.create_index(op.f('ix_order_origin_type'), 'order', ['origin_type'], unique=False)
462op.create_index(op.f('ix_order_partner_id'), 'order', ['partner_id'], unique=False)
463op.create_index(op.f('ix_order_store_id'), 'order', ['store_id'], unique=False)
464op.create_index(op.f('ix_order_user_ids'), 'order', ['user_ids'], unique=False)
465op.create_table('uom',
466sa.Column('id', sa.Uuid(), nullable=False),
467sa.Column('title', sa.String(), nullable=False),
468sa.Column('uom_category_id', sa.Uuid(), nullable=True),
469sa.Column('type', sa.String(), nullable=False),
470sa.Column('ratio', sa.Numeric(precision=12, scale=2), nullable=False),
471sa.Column('precision', sa.Numeric(precision=12, scale=2), nullable=False),
472sa.Column('lsn', sa.BigInteger(), nullable=True),
473sa.Column('company_id', sa.Uuid(), nullable=False),
474sa.Column('created_at', sa.DateTime(),
475server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
476nullable=False),
477sa.Column('updated_at', sa.DateTime(),
478server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
479nullable=True),
480sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
481sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
482sa.ForeignKeyConstraint(['uom_category_id'], ['uom_category.id'], ),
483sa.PrimaryKeyConstraint('id')
484)
485op.create_index(op.f('ix_uom_company_id'), 'uom', ['company_id'], unique=False)
486op.create_index(op.f('ix_uom_id'), 'uom', ['id'], unique=False)
487op.create_index(op.f('ix_uom_lsn'), 'uom', ['lsn'], unique=False)
488op.create_index(op.f('ix_uom_title'), 'uom', ['title'], unique=False)
489op.create_index(op.f('ix_uom_type'), 'uom', ['type'], unique=False)
490op.create_table('user',
491sa.Column('id', sa.Uuid(), nullable=False),
492sa.Column('external_number', sa.String(), nullable=True),
493sa.Column('password', sqlalchemy_utils.types.password.PasswordType(
494
495),
496nullable=False),
497sa.Column('email', sqlalchemy_utils.types.email.EmailType(length=255),
498nullable=True),
499sa.Column('country', sqlalchemy_utils.types.country.CountryType(length=2),
500nullable=False),
501sa.Column('locale', sqlalchemy_utils.types.locale.LocaleType(),
502nullable=False),
503sa.Column('phone_number',
504sqlalchemy_utils.types.phone_number.PhoneNumberType(length=20),
505nullable=True),
506sa.Column('nickname', sa.String(), nullable=False),
507sa.Column('is_admin', sa.Boolean(), nullable=False),
508sa.Column('type', sa.String(), nullable=False),
509sa.Column('store_id', sa.Uuid(), nullable=True),
510sa.Column('company_id', sa.Uuid(), nullable=True),
511sa.Column('company_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
512nullable=False),
513sa.Column('role_ids', sa.ARRAY(sa.Uuid()), server_default='{}', nullable=False),
514sa.Column('created_at', sa.DateTime(),
515server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
516nullable=False),
517sa.Column('updated_at', sa.DateTime(),
518server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
519nullable=True),
520sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
521sa.Column('lsn', sa.BigInteger(), nullable=True),
522sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
523sa.ForeignKeyConstraint(['store_id'], ['store.id'], ),
524sa.PrimaryKeyConstraint('id'),
525sa.UniqueConstraint('email', 'company_ids', name='_user_company_id_uc')
526)
527op.create_index(op.f('ix_user_company_id'), 'user', ['company_id'], unique=False)
528op.create_index(op.f('ix_user_company_ids'), 'user', ['company_ids'], unique=False)
529op.create_index(op.f('ix_user_id'), 'user', ['id'], unique=False)
530op.create_index(op.f('ix_user_lsn'), 'user', ['lsn'], unique=False)
531op.create_index(op.f('ix_user_role_ids'), 'user', ['role_ids'], unique=False)
532op.create_index(op.f('ix_user_store_id'), 'user', ['store_id'], unique=False)
533op.create_table('location',
534sa.Column('title', sa.String(), nullable=False),
535sa.Column('store_id', sa.Uuid(), nullable=True),
536sa.Column('location_class',
537sa.Enum('PARTNER', 'PLACE', 'RESOURCE', 'PACKAGE', 'ZONE', 'LOST',
538'INVENTORY', 'SCRAP', 'SCRAPPED', 'BUFFER',
539name='locationclass'), nullable=False),
540sa.Column('location_type_id', sa.Uuid(), nullable=False),
541sa.Column('location_id', sa.Uuid(), nullable=True),
542sa.Column('is_active', sa.Boolean(), nullable=True),
543sa.Column('allowed_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
544nullable=False),
545sa.Column('exclude_package_ids', sa.ARRAY(sa.Uuid()), server_default='{}',
546nullable=False),
547sa.Column('is_can_negative', sa.Boolean(), server_default=sa.text('false'),
548nullable=True),
549sa.Column('id', sa.Uuid(), nullable=False),
550sa.Column('lsn', sa.BigInteger(), nullable=True),
551sa.Column('company_id', sa.Uuid(), nullable=False),
552sa.Column('created_at', sa.DateTime(),
553server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
554nullable=False),
555sa.Column('updated_at', sa.DateTime(),
556server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
557nullable=True),
558sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
559sa.Column('lot_id', sa.Uuid(), nullable=True),
560sa.Column('partner_id', sa.Uuid(), nullable=True),
561sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
562sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
563sa.ForeignKeyConstraint(['location_type_id'], ['location_type.id'], ),
564sa.ForeignKeyConstraint(['lot_id'], ['lot.id'], ondelete='SET NULL'),
565sa.PrimaryKeyConstraint('id')
566)
567op.create_index(op.f('ix_location_allowed_package_ids'), 'location', ['allowed_package_ids'],
568unique=False)
569op.create_index(op.f('ix_location_company_id'), 'location', ['company_id'], unique=False)
570op.create_index(op.f('ix_location_exclude_package_ids'), 'location', ['exclude_package_ids'],
571unique=False)
572op.create_index(op.f('ix_location_id'), 'location', ['id'], unique=False)
573op.create_index(op.f('ix_location_is_can_negative'), 'location', ['is_can_negative'],
574unique=False)
575op.create_index(op.f('ix_location_location_class'), 'location', ['location_class'],
576unique=False)
577op.create_index(op.f('ix_location_location_id'), 'location', ['location_id'], unique=False)
578op.create_index(op.f('ix_location_location_type_id'), 'location', ['location_type_id'],
579unique=False)
580op.create_index(op.f('ix_location_lot_id'), 'location', ['lot_id'], unique=False)
581op.create_index(op.f('ix_location_lsn'), 'location', ['lsn'], unique=False)
582op.create_index(op.f('ix_location_partner_id'), 'location', ['partner_id'], unique=False)
583op.create_index(op.f('ix_location_store_id'), 'location', ['store_id'], unique=False)
584op.create_index(op.f('ix_location_title'), 'location', ['title'], unique=False)
585op.create_table('partner',
586sa.Column('id', sa.Uuid(), nullable=False),
587sa.Column('title', sa.String(), nullable=False),
588sa.Column('type',
589sa.Enum('PARTNER', 'CONTACT', 'SUBPARTNER', 'INTERCOMPANY', 'STORE',
590'USER', name='partnertype'), nullable=False),
591sa.Column('external_number', sa.String(), nullable=True),
592sa.Column('partner_id', sa.Uuid(), nullable=True),
593sa.Column('phone_number',
594sqlalchemy_utils.types.phone_number.PhoneNumberType(length=20),
595nullable=True),
596sa.Column('email', sqlalchemy_utils.types.email.EmailType(length=255),
597nullable=True),
598sa.Column('country', sqlalchemy_utils.types.country.CountryType(length=2),
599nullable=False),
600sa.Column('created_by', sa.Uuid(), nullable=False),
601sa.Column('locale', sqlalchemy_utils.types.locale.LocaleType(),
602nullable=False),
603sa.Column('currency', sqlalchemy_utils.types.currency.CurrencyType(length=3),
604nullable=False),
605sa.Column('lsn', sa.BigInteger(), nullable=True),
606sa.Column('company_id', sa.Uuid(), nullable=False),
607sa.Column('created_at', sa.DateTime(),
608server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
609nullable=False),
610sa.Column('updated_at', sa.DateTime(),
611server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
612nullable=True),
613sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
614sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
615sa.ForeignKeyConstraint(['created_by'], ['user.id'], ),
616sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
617sa.PrimaryKeyConstraint('id'),
618sa.UniqueConstraint('external_number')
619)
620op.create_index(op.f('ix_partner_company_id'), 'partner', ['company_id'], unique=False)
621op.create_index(op.f('ix_partner_created_by'), 'partner', ['created_by'], unique=False)
622op.create_index(op.f('ix_partner_id'), 'partner', ['id'], unique=False)
623op.create_index(op.f('ix_partner_lsn'), 'partner', ['lsn'], unique=False)
624op.create_index(op.f('ix_partner_partner_id'), 'partner', ['partner_id'], unique=False)
625op.create_index(op.f('ix_partner_title'), 'partner', ['title'], unique=False)
626op.create_table('product',
627sa.Column('id', sa.Uuid(), nullable=False),
628sa.Column('title', sa.String(), nullable=False),
629sa.Column('description', sa.String(), nullable=True),
630sa.Column('image_url', sa.String(), nullable=True),
631sa.Column('external_number', sa.String(), nullable=True),
632sa.Column('product_type', sa.String(), nullable=False),
633sa.Column('uom_id', sa.Uuid(), nullable=False),
634sa.Column('product_category_id', sa.Uuid(), nullable=False),
635sa.Column('barcode_list', postgresql.ARRAY(sa.String()), server_default='{}',
636nullable=False),
637sa.Column('lsn', sa.BigInteger(), nullable=True),
638sa.Column('company_id', sa.Uuid(), nullable=False),
639sa.Column('created_at', sa.DateTime(),
640server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
641nullable=False),
642sa.Column('updated_at', sa.DateTime(),
643server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
644nullable=True),
645sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
646sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
647sa.ForeignKeyConstraint(['product_category_id'], ['product_category.id'], ),
648sa.ForeignKeyConstraint(['uom_id'], ['uom.id'], ),
649sa.PrimaryKeyConstraint('id'),
650sa.UniqueConstraint('external_number', 'company_id',
651name='_product_company_id_uc')
652)
653op.create_index(op.f('ix_product_barcode_list'), 'product', ['barcode_list'], unique=False)
654op.create_index(op.f('ix_product_company_id'), 'product', ['company_id'], unique=False)
655op.create_index(op.f('ix_product_id'), 'product', ['id'], unique=False)
656op.create_index(op.f('ix_product_lsn'), 'product', ['lsn'], unique=False)
657op.create_index(op.f('ix_product_product_category_id'), 'product', ['product_category_id'],
658unique=False)
659op.create_index(op.f('ix_product_title'), 'product', ['title'], unique=False)
660op.create_index(op.f('ix_product_uom_id'), 'product', ['uom_id'], unique=False)
661op.create_table('move_log',
662sa.Column('product_id', sa.Uuid(), nullable=False),
663sa.Column('store_id', sa.Uuid(), nullable=False),
664sa.Column('location_class',
665sa.Enum('PARTNER', 'PLACE', 'RESOURCE', 'PACKAGE', 'ZONE', 'LOST',
666'INVENTORY', 'SCRAP', 'SCRAPPED', 'BUFFER',
667name='locationclass'), nullable=False),
668sa.Column('location_type_id', sa.Uuid(), nullable=False),
669sa.Column('location_id', sa.Uuid(), nullable=True),
670sa.Column('lot_id', sa.Uuid(), nullable=True),
671sa.Column('partner_id', sa.Uuid(), nullable=True),
672sa.Column('quantity', sa.Float(), nullable=False),
673sa.Column('reserved_quantity', sa.Float(), nullable=False),
674sa.Column('id', sa.Uuid(), nullable=False),
675sa.Column('lsn', sa.BigInteger(), nullable=True),
676sa.Column('company_id', sa.Uuid(), nullable=False),
677sa.Column('created_at', sa.DateTime(),
678server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
679nullable=False),
680sa.Column('updated_at', sa.DateTime(),
681server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
682nullable=True),
683sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
684sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
685sa.ForeignKeyConstraint(['location_id'], ['location.id'], ondelete='SET NULL'),
686sa.ForeignKeyConstraint(['location_type_id'], ['location_type.id'],
687ondelete='SET NULL'),
688sa.ForeignKeyConstraint(['lot_id'], ['lot.id'], ondelete='SET NULL'),
689sa.PrimaryKeyConstraint('id')
690)
691op.create_index(op.f('ix_move_log_company_id'), 'move_log', ['company_id'], unique=False)
692op.create_index(op.f('ix_move_log_id'), 'move_log', ['id'], unique=False)
693op.create_index(op.f('ix_move_log_location_class'), 'move_log', ['location_class'],
694unique=False)
695op.create_index(op.f('ix_move_log_location_id'), 'move_log', ['location_id'], unique=False)
696op.create_index(op.f('ix_move_log_location_type_id'), 'move_log', ['location_type_id'],
697unique=False)
698op.create_index(op.f('ix_move_log_lot_id'), 'move_log', ['lot_id'], unique=False)
699op.create_index(op.f('ix_move_log_lsn'), 'move_log', ['lsn'], unique=False)
700op.create_index(op.f('ix_move_log_partner_id'), 'move_log', ['partner_id'], unique=False)
701op.create_index(op.f('ix_move_log_product_id'), 'move_log', ['product_id'], unique=False)
702op.create_index(op.f('ix_move_log_store_id'), 'move_log', ['store_id'], unique=False)
703op.create_table('quant',
704sa.Column('quantity', sa.Float(), nullable=False),
705sa.Column('reserved_quantity', sa.Float(), nullable=False),
706sa.Column('incoming_quantity', sa.Float(), nullable=False),
707sa.Column('expiration_datetime', sa.DateTime(timezone=True), nullable=True),
708sa.Column('uom_id', sa.Uuid(), nullable=False),
709sa.Column('move_ids', sa.ARRAY(sa.Uuid()), server_default='{}', nullable=False),
710sa.Column('id', sa.Uuid(), nullable=False),
711sa.Column('lsn', sa.BigInteger(), nullable=True),
712sa.Column('company_id', sa.Uuid(), nullable=False),
713sa.Column('created_at', sa.DateTime(),
714server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
715nullable=False),
716sa.Column('updated_at', sa.DateTime(),
717server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
718nullable=True),
719sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
720sa.Column('product_id', sa.Uuid(), nullable=False),
721sa.Column('location_type_id', sa.Uuid(), nullable=True),
722sa.Column('location_id', sa.Uuid(), nullable=True),
723sa.Column('store_id', sa.Uuid(), nullable=False),
724sa.Column('location_class',
725sa.Enum('PARTNER', 'PLACE', 'RESOURCE', 'PACKAGE', 'ZONE', 'LOST',
726'INVENTORY', 'SCRAP', 'SCRAPPED', 'BUFFER',
727name='locationclass'), nullable=False),
728sa.Column('lot_id', sa.Uuid(), nullable=True),
729sa.Column('partner_id', sa.Uuid(), nullable=True),
730sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
731sa.ForeignKeyConstraint(['location_id'], ['location.id'], ondelete='SET NULL'),
732sa.ForeignKeyConstraint(['location_type_id'], ['location_type.id'],
733ondelete='SET NULL'),
734sa.ForeignKeyConstraint(['lot_id'], ['lot.id'], ondelete='SET NULL'),
735sa.PrimaryKeyConstraint('id'),
736sa.UniqueConstraint('store_id', 'location_id', 'lot_id', 'expiration_datetime',
737name='_quant_st_loc_lot_ex_id_uc')
738)
739op.create_index(op.f('ix_quant_company_id'), 'quant', ['company_id'], unique=False)
740op.create_index(op.f('ix_quant_id'), 'quant', ['id'], unique=False)
741op.create_index(op.f('ix_quant_location_class'), 'quant', ['location_class'], unique=False)
742op.create_index(op.f('ix_quant_location_id'), 'quant', ['location_id'], unique=False)
743op.create_index(op.f('ix_quant_location_type_id'), 'quant', ['location_type_id'], unique=False)
744op.create_index(op.f('ix_quant_lot_id'), 'quant', ['lot_id'], unique=False)
745op.create_index(op.f('ix_quant_lsn'), 'quant', ['lsn'], unique=False)
746op.create_index(op.f('ix_quant_move_ids'), 'quant', ['move_ids'], unique=False)
747op.create_index(op.f('ix_quant_partner_id'), 'quant', ['partner_id'], unique=False)
748op.create_index(op.f('ix_quant_product_id'), 'quant', ['product_id'], unique=False)
749op.create_index(op.f('ix_quant_store_id'), 'quant', ['store_id'], unique=False)
750op.create_index(op.f('ix_quant_uom_id'), 'quant', ['uom_id'], unique=False)
751op.create_table('move',
752sa.Column('type', sa.Enum('PRODUCT', 'PACKAGE', name='movetype'),
753nullable=False),
754sa.Column('move_id', sa.Uuid(), nullable=True),
755sa.Column('store_id', sa.Uuid(), nullable=False),
756sa.Column('order_type_id', sa.Uuid(), nullable=True),
757sa.Column('order_id', sa.Uuid(), nullable=True),
758sa.Column('location_src_id', sa.Uuid(), nullable=True),
759sa.Column('location_dest_id', sa.Uuid(), nullable=True),
760sa.Column('lot_id', sa.Uuid(), nullable=True),
761sa.Column('location_id', sa.Uuid(), nullable=True),
762sa.Column('product_id', sa.Uuid(), nullable=True),
763sa.Column('partner_id', sa.Uuid(), nullable=True),
764sa.Column('quantity', sa.Float(), nullable=False),
765sa.Column('uom_id', sa.Uuid(), nullable=False),
766sa.Column('quant_src_id', sa.Uuid(), nullable=True),
767sa.Column('quant_dest_id', sa.Uuid(), nullable=True),
768sa.Column('status',
769sa.Enum('CREATED', 'CONFIRMED', 'WAITING', 'ASSIGNED', 'PROCESSING',
770'DONE', 'CANCELED', name='movestatus'), nullable=False),
771sa.Column('id', sa.Uuid(), nullable=False),
772sa.Column('lsn', sa.BigInteger(), nullable=True),
773sa.Column('company_id', sa.Uuid(), nullable=False),
774sa.Column('created_at', sa.DateTime(),
775server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
776nullable=False),
777sa.Column('updated_at', sa.DateTime(),
778server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
779nullable=True),
780sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
781sa.Column('created_by', sa.Uuid(), nullable=False),
782sa.Column('edited_by', sa.Uuid(), nullable=False),
783sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
784sa.ForeignKeyConstraint(['location_dest_id'], ['location.id'],
785ondelete='SET NULL'),
786sa.ForeignKeyConstraint(['location_id'], ['location.id'], ondelete='SET NULL'),
787sa.ForeignKeyConstraint(['location_src_id'], ['location.id'],
788ondelete='SET NULL'),
789sa.ForeignKeyConstraint(['lot_id'], ['lot.id'], ondelete='SET NULL'),
790sa.ForeignKeyConstraint(['move_id'], ['move.id'], ondelete='RESTRICT'),
791sa.ForeignKeyConstraint(['order_id'], ['order.id'], ondelete='RESTRICT'),
792sa.ForeignKeyConstraint(['order_type_id'], ['order_type.id'],
793ondelete='RESTRICT'),
794sa.ForeignKeyConstraint(['quant_dest_id'], ['quant.id'], ondelete='SET NULL'),
795sa.ForeignKeyConstraint(['quant_src_id'], ['quant.id'], ondelete='SET NULL'),
796sa.PrimaryKeyConstraint('id')
797)
798op.create_index(op.f('ix_move_company_id'), 'move', ['company_id'], unique=False)
799op.create_index(op.f('ix_move_created_by'), 'move', ['created_by'], unique=False)
800op.create_index(op.f('ix_move_edited_by'), 'move', ['edited_by'], unique=False)
801op.create_index(op.f('ix_move_id'), 'move', ['id'], unique=False)
802op.create_index(op.f('ix_move_lsn'), 'move', ['lsn'], unique=False)
803op.create_index(op.f('ix_move_partner_id'), 'move', ['partner_id'], unique=False)
804op.create_index(op.f('ix_move_product_id'), 'move', ['product_id'], unique=False)
805op.create_index(op.f('ix_move_quant_dest_id'), 'move', ['quant_dest_id'], unique=False)
806op.create_index(op.f('ix_move_quant_src_id'), 'move', ['quant_src_id'], unique=False)
807op.create_index(op.f('ix_move_store_id'), 'move', ['store_id'], unique=False)
808op.create_index(op.f('ix_move_uom_id'), 'move', ['uom_id'], unique=False)
809op.create_table('suggest',
810sa.Column('move_id', sa.Uuid(), nullable=False),
811sa.Column('priority', sa.Integer(), nullable=False),
812sa.Column('type',
813sa.Enum('IN_QUANTITY', 'IN_PRODUCT', 'IN_PACKAGE', 'IN_LOCATION',
814'IN_LOT', 'IN_RESOURCE', 'IN_VALID', 'NEW_PACKAGE', 'NEW_LOT',
815name='suggesttype'), nullable=False),
816sa.Column('value', sa.String(), nullable=True),
817sa.Column('result_value', sa.String(), nullable=True),
818sa.Column('user_id', sa.Uuid(), nullable=True),
819sa.Column('status', sa.Enum('WAITING', 'DONE', name='suggeststatus'),
820nullable=False),
821sa.Column('id', sa.Uuid(), nullable=False),
822sa.Column('lsn', sa.BigInteger(), nullable=True),
823sa.Column('company_id', sa.Uuid(), nullable=False),
824sa.Column('created_at', sa.DateTime(),
825server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
826nullable=False),
827sa.Column('updated_at', sa.DateTime(),
828server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"),
829nullable=True),
830sa.Column('vars', sqlalchemy_utils.types.json.JSONType(), nullable=True),
831sa.ForeignKeyConstraint(['company_id'], ['company.id'], ),
832sa.ForeignKeyConstraint(['move_id'], ['move.id'], ondelete='CASCADE'),
833sa.PrimaryKeyConstraint('id')
834)
835op.create_index(op.f('ix_suggest_company_id'), 'suggest', ['company_id'], unique=False)
836op.create_index(op.f('ix_suggest_id'), 'suggest', ['id'], unique=False)
837op.create_index(op.f('ix_suggest_lsn'), 'suggest', ['lsn'], unique=False)
838op.create_index(op.f('ix_suggest_move_id'), 'suggest', ['move_id'], unique=False)
839op.create_index(op.f('ix_suggest_status'), 'suggest', ['status'], unique=False)
840op.create_index(op.f('ix_suggest_user_id'), 'suggest', ['user_id'], unique=False)
841# ### end Alembic commands ###
842op.execute("create sequence suggest_lsn_seq")
843op.execute("create sequence order_type_lsn_seq")
844op.execute("create sequence order_lsn_seq")
845op.execute("create sequence move_lsn_seq")
846op.execute("create sequence move_log_lsn_seq")
847op.execute("create sequence location_lsn_seq")
848op.execute("create sequence location_type_lsn_seq")
849op.execute("create sequence lot_lsn_seq")
850op.execute("create sequence product_storage_type_lsn_seq")
851op.execute("create sequence quant_lsn_seq")
852op.execute("create sequence channel_lsn_seq")
853op.execute("create sequence product_lsn_seq")
854op.execute("create sequence product_category_lsn_seq")
855op.execute("create sequence permission_lsn_seq")
856op.execute("create sequence role_lsn_seq")
857op.execute("create sequence partner_lsn_seq")
858op.execute("create sequence uom_lsn_seq")
859op.execute("create sequence uom_category_lsn_seq")
860op.execute("create sequence company_lsn_seq")
861op.execute("create sequence user_lsn_seq")
862op.execute("create sequence store_lsn_seq")
863op.execute("create sequence storage_type_lsn_seq")
864op.execute("create sequence bus_lsn_seq")
865
866
867def downgrade():
868# ### commands auto generated by Alembic - please adjust! ###
869op.drop_index(op.f('ix_suggest_user_id'), table_name='suggest')
870op.drop_index(op.f('ix_suggest_status'), table_name='suggest')
871op.drop_index(op.f('ix_suggest_move_id'), table_name='suggest')
872op.drop_index(op.f('ix_suggest_lsn'), table_name='suggest')
873op.drop_index(op.f('ix_suggest_id'), table_name='suggest')
874op.drop_index(op.f('ix_suggest_company_id'), table_name='suggest')
875op.drop_table('suggest')
876op.drop_index(op.f('ix_move_uom_id'), table_name='move')
877op.drop_index(op.f('ix_move_store_id'), table_name='move')
878op.drop_index(op.f('ix_move_quant_src_id'), table_name='move')
879op.drop_index(op.f('ix_move_quant_dest_id'), table_name='move')
880op.drop_index(op.f('ix_move_product_id'), table_name='move')
881op.drop_index(op.f('ix_move_partner_id'), table_name='move')
882op.drop_index(op.f('ix_move_lsn'), table_name='move')
883op.drop_index(op.f('ix_move_id'), table_name='move')
884op.drop_index(op.f('ix_move_edited_by'), table_name='move')
885op.drop_index(op.f('ix_move_created_by'), table_name='move')
886op.drop_index(op.f('ix_move_company_id'), table_name='move')
887op.drop_table('move')
888op.drop_index(op.f('ix_quant_uom_id'), table_name='quant')
889op.drop_index(op.f('ix_quant_store_id'), table_name='quant')
890op.drop_index(op.f('ix_quant_product_id'), table_name='quant')
891op.drop_index(op.f('ix_quant_partner_id'), table_name='quant')
892op.drop_index(op.f('ix_quant_move_ids'), table_name='quant')
893op.drop_index(op.f('ix_quant_lsn'), table_name='quant')
894op.drop_index(op.f('ix_quant_lot_id'), table_name='quant')
895op.drop_index(op.f('ix_quant_location_type_id'), table_name='quant')
896op.drop_index(op.f('ix_quant_location_id'), table_name='quant')
897op.drop_index(op.f('ix_quant_location_class'), table_name='quant')
898op.drop_index(op.f('ix_quant_id'), table_name='quant')
899op.drop_index(op.f('ix_quant_company_id'), table_name='quant')
900op.drop_table('quant')
901op.drop_index(op.f('ix_move_log_store_id'), table_name='move_log')
902op.drop_index(op.f('ix_move_log_product_id'), table_name='move_log')
903op.drop_index(op.f('ix_move_log_partner_id'), table_name='move_log')
904op.drop_index(op.f('ix_move_log_lsn'), table_name='move_log')
905op.drop_index(op.f('ix_move_log_lot_id'), table_name='move_log')
906op.drop_index(op.f('ix_move_log_location_type_id'), table_name='move_log')
907op.drop_index(op.f('ix_move_log_location_id'), table_name='move_log')
908op.drop_index(op.f('ix_move_log_location_class'), table_name='move_log')
909op.drop_index(op.f('ix_move_log_id'), table_name='move_log')
910op.drop_index(op.f('ix_move_log_company_id'), table_name='move_log')
911op.drop_table('move_log')
912op.drop_index(op.f('ix_product_uom_id'), table_name='product')
913op.drop_index(op.f('ix_product_title'), table_name='product')
914op.drop_index(op.f('ix_product_product_category_id'), table_name='product')
915op.drop_index(op.f('ix_product_lsn'), table_name='product')
916op.drop_index(op.f('ix_product_id'), table_name='product')
917op.drop_index(op.f('ix_product_company_id'), table_name='product')
918op.drop_index(op.f('ix_product_barcode_list'), table_name='product')
919op.drop_table('product')
920op.drop_index(op.f('ix_partner_title'), table_name='partner')
921op.drop_index(op.f('ix_partner_partner_id'), table_name='partner')
922op.drop_index(op.f('ix_partner_lsn'), table_name='partner')
923op.drop_index(op.f('ix_partner_id'), table_name='partner')
924op.drop_index(op.f('ix_partner_created_by'), table_name='partner')
925op.drop_index(op.f('ix_partner_company_id'), table_name='partner')
926op.drop_table('partner')
927op.drop_index(op.f('ix_location_title'), table_name='location')
928op.drop_index(op.f('ix_location_store_id'), table_name='location')
929op.drop_index(op.f('ix_location_partner_id'), table_name='location')
930op.drop_index(op.f('ix_location_lsn'), table_name='location')
931op.drop_index(op.f('ix_location_lot_id'), table_name='location')
932op.drop_index(op.f('ix_location_location_type_id'), table_name='location')
933op.drop_index(op.f('ix_location_location_id'), table_name='location')
934op.drop_index(op.f('ix_location_location_class'), table_name='location')
935op.drop_index(op.f('ix_location_is_can_negative'), table_name='location')
936op.drop_index(op.f('ix_location_id'), table_name='location')
937op.drop_index(op.f('ix_location_exclude_package_ids'), table_name='location')
938op.drop_index(op.f('ix_location_company_id'), table_name='location')
939op.drop_index(op.f('ix_location_allowed_package_ids'), table_name='location')
940op.drop_table('location')
941op.drop_index(op.f('ix_user_store_id'), table_name='user')
942op.drop_index(op.f('ix_user_role_ids'), table_name='user')
943op.drop_index(op.f('ix_user_lsn'), table_name='user')
944op.drop_index(op.f('ix_user_id'), table_name='user')
945op.drop_index(op.f('ix_user_company_ids'), table_name='user')
946op.drop_index(op.f('ix_user_company_id'), table_name='user')
947op.drop_table('user')
948op.drop_index(op.f('ix_uom_type'), table_name='uom')
949op.drop_index(op.f('ix_uom_title'), table_name='uom')
950op.drop_index(op.f('ix_uom_lsn'), table_name='uom')
951op.drop_index(op.f('ix_uom_id'), table_name='uom')
952op.drop_index(op.f('ix_uom_company_id'), table_name='uom')
953op.drop_table('uom')
954op.drop_index(op.f('ix_order_user_ids'), table_name='order')
955op.drop_index(op.f('ix_order_store_id'), table_name='order')
956op.drop_index(op.f('ix_order_partner_id'), table_name='order')
957op.drop_index(op.f('ix_order_origin_type'), table_name='order')
958op.drop_index(op.f('ix_order_origin_number'), table_name='order')
959op.drop_index(op.f('ix_order_number'), table_name='order')
960op.drop_index(op.f('ix_order_lsn'), table_name='order')
961op.drop_index(op.f('ix_order_id'), table_name='order')
962op.drop_index(op.f('ix_order_edited_by'), table_name='order')
963op.drop_index(op.f('ix_order_created_by'), table_name='order')
964op.drop_index(op.f('ix_order_company_id'), table_name='order')
965op.drop_table('order')
966op.drop_index(op.f('ix_location_type_title'), table_name='location_type')
967op.drop_index(op.f('ix_location_type_store_id'), table_name='location_type')
968op.drop_index(op.f('ix_location_type_partner_id'), table_name='location_type')
969op.drop_index(op.f('ix_location_type_lsn'), table_name='location_type')
970op.drop_index(op.f('ix_location_type_lot_id'), table_name='location_type')
971op.drop_index(op.f('ix_location_type_location_class'), table_name='location_type')
972op.drop_index(op.f('ix_location_type_is_homogeneity'), table_name='location_type')
973op.drop_index(op.f('ix_location_type_is_can_negative'), table_name='location_type')
974op.drop_index(op.f('ix_location_type_id'), table_name='location_type')
975op.drop_index(op.f('ix_location_type_exclude_package_ids'), table_name='location_type')
976op.drop_index(op.f('ix_location_type_company_id'), table_name='location_type')
977op.drop_index(op.f('ix_location_type_allowed_package_ids'), table_name='location_type')
978op.drop_table('location_type')
979op.drop_index(op.f('ix_uom_category_title'), table_name='uom_category')
980op.drop_index(op.f('ix_uom_category_lsn'), table_name='uom_category')
981op.drop_index(op.f('ix_uom_category_id'), table_name='uom_category')
982op.drop_index(op.f('ix_uom_category_company_id'), table_name='uom_category')
983op.drop_table('uom_category')
984op.drop_index(op.f('ix_store_title'), table_name='store')
985op.drop_index(op.f('ix_store_lsn'), table_name='store')
986op.drop_index(op.f('ix_store_id'), table_name='store')
987op.drop_index(op.f('ix_store_company_id'), table_name='store')
988op.drop_table('store')
989op.drop_index(op.f('ix_storage_type_lsn'), table_name='storage_type')
990op.drop_index(op.f('ix_storage_type_id'), table_name='storage_type')
991op.drop_index(op.f('ix_storage_type_company_id'), table_name='storage_type')
992op.drop_table('storage_type')
993op.drop_index(op.f('ix_role_title'), table_name='role')
994op.drop_index(op.f('ix_role_role_ids'), table_name='role')
995op.drop_index(op.f('ix_role_permission_allow_list'), table_name='role')
996op.drop_index(op.f('ix_role_lsn'), table_name='role')
997op.drop_index(op.f('ix_role_id'), table_name='role')
998op.drop_index(op.f('ix_role_company_id'), table_name='role')
999op.drop_table('role')
1000op.drop_index(op.f('ix_product_storage_type_product_id'), table_name='product_storage_type')
1001op.drop_index(op.f('ix_product_storage_type_lsn'), table_name='product_storage_type')
1002op.drop_index(op.f('ix_product_storage_type_id'), table_name='product_storage_type')
1003op.drop_index(op.f('ix_product_storage_type_exclude_package_ids'),
1004table_name='product_storage_type')
1005op.drop_index(op.f('ix_product_storage_type_company_id'), table_name='product_storage_type')
1006op.drop_index(op.f('ix_product_storage_type_allowed_package_ids'),
1007table_name='product_storage_type')
1008op.drop_table('product_storage_type')
1009op.drop_index(op.f('ix_product_category_title'), table_name='product_category')
1010op.drop_index(op.f('ix_product_category_product_category_ids'), table_name='product_category')
1011op.drop_index(op.f('ix_product_category_lsn'), table_name='product_category')
1012op.drop_index(op.f('ix_product_category_id'), table_name='product_category')
1013op.drop_index(op.f('ix_product_category_company_id'), table_name='product_category')
1014op.drop_table('product_category')
1015op.drop_index(op.f('ix_order_type_title'), table_name='order_type')
1016op.drop_index(op.f('ix_order_type_store_id'), table_name='order_type')
1017op.drop_index(op.f('ix_order_type_prefix'), table_name='order_type')
1018op.drop_index(op.f('ix_order_type_partner_id'), table_name='order_type')
1019op.drop_index(op.f('ix_order_type_lsn'), table_name='order_type')
1020op.drop_index(op.f('ix_order_type_id'), table_name='order_type')
1021op.drop_index(op.f('ix_order_type_exclude_package_ids'), table_name='order_type')
1022op.drop_index(op.f('ix_order_type_exclude_location_type_src_ids'), table_name='order_type')
1023op.drop_index(op.f('ix_order_type_exclude_location_type_dest_ids'), table_name='order_type')
1024op.drop_index(op.f('ix_order_type_exclude_location_src_ids'), table_name='order_type')
1025op.drop_index(op.f('ix_order_type_exclude_location_dest_ids'), table_name='order_type')
1026op.drop_index(op.f('ix_order_type_exclude_location_class_src_ids'), table_name='order_type')
1027op.drop_index(op.f('ix_order_type_exclude_location_class_dest_ids'), table_name='order_type')
1028op.drop_index(op.f('ix_order_type_edited_by'), table_name='order_type')
1029op.drop_index(op.f('ix_order_type_created_by'), table_name='order_type')
1030op.drop_index(op.f('ix_order_type_company_id'), table_name='order_type')
1031op.drop_index(op.f('ix_order_type_allowed_package_ids'), table_name='order_type')
1032op.drop_index(op.f('ix_order_type_allowed_location_type_src_ids'), table_name='order_type')
1033op.drop_index(op.f('ix_order_type_allowed_location_type_dest_ids'), table_name='order_type')
1034op.drop_index(op.f('ix_order_type_allowed_location_src_ids'), table_name='order_type')
1035op.drop_index(op.f('ix_order_type_allowed_location_dest_ids'), table_name='order_type')
1036op.drop_index(op.f('ix_order_type_allowed_location_class_src_ids'), table_name='order_type')
1037op.drop_index(op.f('ix_order_type_allowed_location_class_dest_ids'), table_name='order_type')
1038op.drop_table('order_type')
1039op.drop_index(op.f('ix_lot_product_id'), table_name='lot')
1040op.drop_index(op.f('ix_lot_partner_id'), table_name='lot')
1041op.drop_index(op.f('ix_lot_lsn'), table_name='lot')
1042op.drop_index(op.f('ix_lot_id'), table_name='lot')
1043op.drop_index(op.f('ix_lot_company_id'), table_name='lot')
1044op.drop_table('lot')
1045op.drop_index(op.f('ix_bus_status'), table_name='bus')
1046op.drop_index(op.f('ix_bus_lsn'), table_name='bus')
1047op.drop_index(op.f('ix_bus_id'), table_name='bus')
1048op.drop_index(op.f('ix_bus_company_id'), table_name='bus')
1049op.drop_index(op.f('ix_bus_cache_tag'), table_name='bus')
1050op.drop_table('bus')
1051op.drop_index(op.f('ix_company_title'), table_name='company')
1052op.drop_index(op.f('ix_company_lsn'), table_name='company')
1053op.drop_index(op.f('ix_company_id'), table_name='company')
1054op.drop_table('company')
1055# ### end Alembic commands ###
1056op.execute("drop sequence suggest_lsn_seq")
1057op.execute("drop sequence order_type_lsn_seq")
1058op.execute("drop sequence order_lsn_seq")
1059op.execute("drop sequence move_lsn_seq")
1060op.execute("drop sequence move_log_lsn_seq")
1061op.execute("drop sequence location_lsn_seq")
1062op.execute("drop sequence location_type_lsn_seq")
1063op.execute("drop sequence lot_lsn_seq")
1064op.execute("drop sequence product_storage_type_lsn_seq")
1065op.execute("drop sequence quant_lsn_seq")
1066op.execute("drop sequence channel_lsn_seq")
1067op.execute("drop sequence product_lsn_seq")
1068op.execute("drop sequence product_category_lsn_seq")
1069op.execute("drop sequence permission_lsn_seq")
1070op.execute("drop sequence role_lsn_seq")
1071op.execute("drop sequence partner_lsn_seq")
1072op.execute("drop sequence uom_lsn_seq")
1073op.execute("drop sequence uom_category_lsn_seq")
1074op.execute("drop sequence company_lsn_seq")
1075op.execute("drop sequence user_lsn_seq")
1076op.execute("drop sequence contractor_lsn_seq")
1077op.execute("drop sequence store_lsn_seq")
1078op.execute("drop sequence storage_type_lsn_seq")
1079op.execute("drop sequence bus_lsn_seq")
1080