refactor(api): split Axum handlers into handler/service/repo modules
Keep the REST contract; move domain logic out of route files so checkout, fulfillment, and identity can be reused across customer, shop, and admin surfaces. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
e457339847
commit
5e866d08f4
@@ -0,0 +1,22 @@
|
||||
-- Address book: per-customer saved shipping addresses with a single default.
|
||||
-- The default invariant is enforced by the partial unique index; handlers keep
|
||||
-- it via transactional unset-then-set.
|
||||
|
||||
CREATE TABLE addresses (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id UUID NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
||||
recipient TEXT NOT NULL,
|
||||
phone TEXT NOT NULL,
|
||||
country TEXT NOT NULL,
|
||||
region TEXT NOT NULL DEFAULT '',
|
||||
city TEXT NOT NULL,
|
||||
line1 TEXT NOT NULL,
|
||||
postal_code TEXT NOT NULL DEFAULT '',
|
||||
is_default BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX addresses_user_idx ON addresses (user_id);
|
||||
|
||||
CREATE UNIQUE INDEX addresses_one_default_idx ON addresses (user_id) WHERE is_default;
|
||||
Reference in New Issue
Block a user