added Mercado Pago integration with new payment handling functions and updated app routing
This commit is contained in:
19
db/migrations/20260114130000_product_aliases.sql
Normal file
19
db/migrations/20260114130000_product_aliases.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- migrate:up
|
||||
create table if not exists product_aliases (
|
||||
tenant_id uuid not null references tenants(id) on delete cascade,
|
||||
alias text not null,
|
||||
normalized_alias text not null,
|
||||
woo_product_id integer null,
|
||||
category_hint text null,
|
||||
boost numeric(6,3) not null default 0.0,
|
||||
metadata jsonb not null default '{}'::jsonb,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now(),
|
||||
primary key (tenant_id, alias)
|
||||
);
|
||||
|
||||
create index if not exists product_aliases_tenant_norm_idx
|
||||
on product_aliases (tenant_id, normalized_alias);
|
||||
|
||||
-- migrate:down
|
||||
drop table if exists product_aliases;
|
||||
16
db/migrations/20260114130100_product_embeddings_cache.sql
Normal file
16
db/migrations/20260114130100_product_embeddings_cache.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- migrate:up
|
||||
create table if not exists product_embeddings_cache (
|
||||
tenant_id uuid not null references tenants(id) on delete cascade,
|
||||
content_hash text not null,
|
||||
content_text text not null,
|
||||
embedding jsonb not null,
|
||||
model text not null,
|
||||
updated_at timestamptz not null default now(),
|
||||
primary key (tenant_id, content_hash)
|
||||
);
|
||||
|
||||
create index if not exists product_embeddings_cache_tenant_idx
|
||||
on product_embeddings_cache (tenant_id);
|
||||
|
||||
-- migrate:down
|
||||
drop table if exists product_embeddings_cache;
|
||||
19
db/migrations/20260114130200_mp_payments.sql
Normal file
19
db/migrations/20260114130200_mp_payments.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- migrate:up
|
||||
create table if not exists mp_payments (
|
||||
tenant_id uuid not null references tenants(id) on delete cascade,
|
||||
woo_order_id bigint null,
|
||||
preference_id text null,
|
||||
payment_id text null,
|
||||
status text null,
|
||||
paid_at timestamptz null,
|
||||
raw jsonb not null default '{}'::jsonb,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now(),
|
||||
primary key (tenant_id, payment_id)
|
||||
);
|
||||
|
||||
create index if not exists mp_payments_tenant_order_idx
|
||||
on mp_payments (tenant_id, woo_order_id);
|
||||
|
||||
-- migrate:down
|
||||
drop table if exists mp_payments;
|
||||
46
db/migrations/20260114131000_product_aliases_seed_ar.sql
Normal file
46
db/migrations/20260114131000_product_aliases_seed_ar.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- migrate:up
|
||||
-- Seed básico de regionalismos AR para aliases de producto.
|
||||
-- Nota: estos alias no fijan woo_product_id (se resuelven por retrieval).
|
||||
insert into product_aliases (tenant_id, alias, normalized_alias, woo_product_id, category_hint, boost, metadata)
|
||||
select t.id, v.alias, v.normalized_alias, null, v.category_hint, v.boost, v.metadata
|
||||
from tenants t
|
||||
cross join (
|
||||
values
|
||||
('asado', 'asado', 'vacuno', 0.20, '{"region":"AR","notes":"corte general"}'::jsonb),
|
||||
('tira de asado', 'tira de asado', 'vacuno', 0.25, '{"region":"AR"}'::jsonb),
|
||||
('asado banderita', 'asado banderita', 'vacuno', 0.25, '{"region":"AR"}'::jsonb),
|
||||
('vacio', 'vacio', 'vacuno', 0.25, '{"region":"AR","alt":"vacío"}'::jsonb),
|
||||
('vacío', 'vacio', 'vacuno', 0.25, '{"region":"AR","alt":"vacio"}'::jsonb),
|
||||
('entraña', 'entrana', 'vacuno', 0.25, '{"region":"AR"}'::jsonb),
|
||||
('matambre', 'matambre', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('colita de cuadril', 'colita de cuadril', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('tapa de asado', 'tapa de asado', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('bife de chorizo', 'bife de chorizo', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('ojo de bife', 'ojo de bife', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('nalga', 'nalga', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('bola de lomo', 'bola de lomo', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('paleta', 'paleta', 'vacuno', 0.15, '{"region":"AR"}'::jsonb),
|
||||
('roast beef', 'roast beef', 'vacuno', 0.15, '{"region":"AR","alt":"rosbif"}'::jsonb),
|
||||
('rosbif', 'rosbif', 'vacuno', 0.15, '{"region":"AR","alt":"roast beef"}'::jsonb),
|
||||
('peceto', 'peceto', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('tapa de nalga', 'tapa de nalga', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('tortuguita', 'tortuguita', 'vacuno', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('carre', 'carre', 'cerdo', 0.20, '{"region":"AR","alt":"carré"}'::jsonb),
|
||||
('carré', 'carre', 'cerdo', 0.20, '{"region":"AR","alt":"carre"}'::jsonb),
|
||||
('bondiola', 'bondiola', 'cerdo', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('matambrito de cerdo', 'matambrito de cerdo', 'cerdo', 0.20, '{"region":"AR"}'::jsonb),
|
||||
('panceta', 'panceta', 'cerdo', 0.15, '{"region":"AR"}'::jsonb),
|
||||
('chorizo', 'chorizo', 'embutidos', 0.10, '{"region":"AR"}'::jsonb),
|
||||
('morcilla', 'morcilla', 'embutidos', 0.10, '{"region":"AR"}'::jsonb),
|
||||
('salchicha parrillera', 'salchicha parrillera', 'embutidos', 0.10, '{"region":"AR"}'::jsonb),
|
||||
('achuras', 'achuras', 'achuras', 0.10, '{"region":"AR"}'::jsonb),
|
||||
('chinchulines', 'chinchulines', 'achuras', 0.10, '{"region":"AR"}'::jsonb),
|
||||
('molleja', 'molleja', 'achuras', 0.10, '{"region":"AR"}'::jsonb),
|
||||
('riñon', 'rinon', 'achuras', 0.10, '{"region":"AR","alt":"riñón"}'::jsonb),
|
||||
('riñón', 'rinon', 'achuras', 0.10, '{"region":"AR","alt":"riñon"}'::jsonb)
|
||||
) as v(alias, normalized_alias, category_hint, boost, metadata)
|
||||
on conflict (tenant_id, alias) do nothing;
|
||||
|
||||
-- migrate:down
|
||||
delete from product_aliases
|
||||
where metadata->>'region' = 'AR';
|
||||
Reference in New Issue
Block a user