Files
aura-crm/production/backend/migrations/012_order_numbers.sql
T

12 lines
409 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- +goose Up
-- Per-prefix atomic counter for human-readable order numbers (e.g. Н00001
-- for a laptop repair, З00001 for a cartridge refill) — see internal/ordernum.
CREATE TABLE order_number_sequences (
prefix TEXT PRIMARY KEY,
next_value INT NOT NULL DEFAULT 1
);
ALTER TABLE orders ADD COLUMN order_number TEXT UNIQUE;
ALTER TABLE cartridge_batches ADD COLUMN order_number TEXT UNIQUE;