Merge main into fix-pdf-check
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
app/migrations/202611111200_montador-interno-stamps.sql
Normal file
24
app/migrations/202611111200_montador-interno-stamps.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- Front 7a.3: a brand per stamp, for the future catalogue, and the montador's
|
||||
-- fixed internal customer. The brand is only recorded here for now; nothing
|
||||
-- else reads it yet (Marcus, 2026-11-10).
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.stamps (
|
||||
code text PRIMARY KEY CHECK (code ~ '^[A-Za-z0-9_-]{1,40}$'),
|
||||
brand text NOT NULL DEFAULT '',
|
||||
public boolean NOT NULL DEFAULT false,
|
||||
updated_by text NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- The one customer every Interno order belongs to (the marketplace's own
|
||||
-- sales). Gestão completes it; until then an Interno order is refused.
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.internal_customer (
|
||||
id integer PRIMARY KEY DEFAULT 1 CHECK (id=1),
|
||||
name text NOT NULL DEFAULT '',
|
||||
cnpj text NOT NULL DEFAULT '',
|
||||
zap text NOT NULL DEFAULT '',
|
||||
mail text NOT NULL DEFAULT '',
|
||||
updated_by text NOT NULL DEFAULT 'sistema',
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
INSERT INTO dtf_local.internal_customer(id,name) VALUES(1,'Nexstar · Marketplace')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
17
app/migrations/202611111200_premium-product.sql
Normal file
17
app/migrations/202611111200_premium-product.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Front 3: the Premium product (Marcus, 2026-11-10), built and switched OFF
|
||||
-- until Dropstar prints the three test sheets and says "testado". The products
|
||||
-- CHECK is the inline constraint of dtf_local.products.id, which Postgres
|
||||
-- named products_id_check; widening a list is a new migration that drops and
|
||||
-- adds that one constraint (never schema.sql).
|
||||
ALTER TABLE dtf_local.products DROP CONSTRAINT IF EXISTS products_id_check;
|
||||
ALTER TABLE dtf_local.products ADD CONSTRAINT products_id_check
|
||||
CHECK (id IN ('file','avulsa','uvfile','uv','premium','tratamento'));
|
||||
|
||||
INSERT INTO dtf_local.products(id, enabled) VALUES ('premium', false)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- A coupon may also target the new product (the Site tab lists every mode).
|
||||
ALTER TABLE dtf_local.coupons DROP CONSTRAINT IF EXISTS coupons_product_check;
|
||||
ALTER TABLE dtf_local.coupons ADD CONSTRAINT coupons_product_check
|
||||
CHECK (product IN ('file','avulsa','uvfile','uv','premium'));
|
||||
|
||||
12
app/migrations/202611111530_label-prints.sql
Normal file
12
app/migrations/202611111530_label-prints.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Front 10: the 10x15 cm label at Finalizado (Marcus, 2026-11-10). One 'auto'
|
||||
-- print per order, decided by the unique partial index, so two computers
|
||||
-- asking at once cannot both print it; a reprint is always another row.
|
||||
CREATE TABLE IF NOT EXISTS dtf_local.label_prints (
|
||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
order_id uuid NOT NULL REFERENCES dtf_local.orders(id) ON DELETE CASCADE,
|
||||
reason text NOT NULL CHECK (reason IN ('auto','reprint')),
|
||||
printed_by text NOT NULL,
|
||||
printed_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS label_prints_one_auto
|
||||
ON dtf_local.label_prints(order_id) WHERE reason='auto';
|
||||
Reference in New Issue
Block a user